11import assert from 'node:assert' ;
2- import { utils } from '../src/index.js' ;
32import { describe , it } from 'node:test' ;
3+ import { treeModifier , applyIteratively , logger } from '../src/index.js' ;
44
55describe ( 'Utils tests: treeModifier' , ( ) => {
66 it ( `Verify treeModifier sets a generic function name` , ( ) => {
77 const expectedFuncName = 'func' ;
8- const generatedFunc = utils . treeModifier ( ( ) => { } , ( ) => { } ) ;
8+ const generatedFunc = treeModifier ( ( ) => { } , ( ) => { } ) ;
99 assert . equal ( generatedFunc . name , expectedFuncName , `The default name of the generated function does not match` ) ;
1010 } ) ;
1111 it ( `Verify treeModifier sets the function's name properly` , ( ) => {
1212 const expectedFuncName = 'expectedFuncName' ;
13- const generatedFunc = utils . treeModifier ( ( ) => { } , ( ) => { } , expectedFuncName ) ;
13+ const generatedFunc = treeModifier ( ( ) => { } , ( ) => { } , expectedFuncName ) ;
1414 assert . equal ( generatedFunc . name , expectedFuncName , `The name of the generated function does not match` ) ;
1515 } ) ;
1616} ) ;
@@ -20,15 +20,15 @@ describe('Utils tests: applyIteratively', () => {
2020 const expectedOutput = code ;
2121 const f = n => n . type === 'Program' ;
2222 const m = ( n , arb ) => arb . markNode ( n ) ;
23- const generatedFunc = utils . treeModifier ( f , m ) ;
24- const result = utils . applyIteratively ( code , [ generatedFunc ] ) ;
23+ const generatedFunc = treeModifier ( f , m ) ;
24+ const result = applyIteratively ( code , [ generatedFunc ] ) ;
2525
2626 assert . equal ( result , expectedOutput , `Result does not match expected output` ) ;
2727 } ) ;
2828 it ( 'Verify applyIteratively catches a critical exception' , ( ) => {
2929 const code = `a` ;
3030 // noinspection JSCheckFunctionSignatures
31- const result = utils . applyIteratively ( code , { length : 4 } ) ;
31+ const result = applyIteratively ( code , { length : 4 } ) ;
3232 assert . equal ( result , code , `Result does not match expected output` ) ;
3333 } ) ;
3434 it ( 'Verify applyIteratively works as expected' , ( ) => {
@@ -44,39 +44,39 @@ describe('Utils tests: applyIteratively', () => {
4444 type : 'Literal' ,
4545 value : replacements [ n . value ] ,
4646 } ) ;
47- const generatedFunc = utils . treeModifier ( f , m ) ;
48- result = utils . applyIteratively ( result , [ generatedFunc ] ) ;
47+ const generatedFunc = treeModifier ( f , m ) ;
48+ result = applyIteratively ( result , [ generatedFunc ] ) ;
4949
5050 assert . equal ( result , expectedOutput , `Result does not match expected output` ) ;
5151 } ) ;
5252} ) ;
5353describe ( 'Utils tests: logger' , ( ) => {
5454 it ( `Verify logger sets the log level to DEBUG properly` , ( ) => {
55- const expectedLogLevel = utils . logger . logLevels . DEBUG ;
56- utils . logger . setLogLevelDebug ( ) ;
57- assert . equal ( utils . logger . currentLogLevel , expectedLogLevel , `The log level DEBUG was not set properly` ) ;
55+ const expectedLogLevel = logger . logLevels . DEBUG ;
56+ logger . setLogLevelDebug ( ) ;
57+ assert . equal ( logger . currentLogLevel , expectedLogLevel , `The log level DEBUG was not set properly` ) ;
5858 } ) ;
5959 it ( `Verify logger sets the log level to NONE properly` , ( ) => {
60- const expectedLogLevel = utils . logger . logLevels . NONE ;
61- utils . logger . setLogLevelNone ( ) ;
62- assert . equal ( utils . logger . currentLogLevel , expectedLogLevel , `The log level NONE was not set properly` ) ;
60+ const expectedLogLevel = logger . logLevels . NONE ;
61+ logger . setLogLevelNone ( ) ;
62+ assert . equal ( logger . currentLogLevel , expectedLogLevel , `The log level NONE was not set properly` ) ;
6363 } ) ;
6464 it ( `Verify logger sets the log level to LOG properly` , ( ) => {
65- const expectedLogLevel = utils . logger . logLevels . LOG ;
66- utils . logger . setLogLevelLog ( ) ;
67- assert . equal ( utils . logger . currentLogLevel , expectedLogLevel , `The log level LOG was not set properly` ) ;
65+ const expectedLogLevel = logger . logLevels . LOG ;
66+ logger . setLogLevelLog ( ) ;
67+ assert . equal ( logger . currentLogLevel , expectedLogLevel , `The log level LOG was not set properly` ) ;
6868 } ) ;
6969 it ( `Verify logger sets the log level to ERROR properly` , ( ) => {
70- const expectedLogLevel = utils . logger . logLevels . ERROR ;
71- utils . logger . setLogLevelError ( ) ;
72- assert . equal ( utils . logger . currentLogLevel , expectedLogLevel , `The log level ERROR was not set properly` ) ;
70+ const expectedLogLevel = logger . logLevels . ERROR ;
71+ logger . setLogLevelError ( ) ;
72+ assert . equal ( logger . currentLogLevel , expectedLogLevel , `The log level ERROR was not set properly` ) ;
7373 } ) ;
7474 it ( `Verify logger sets the log function properly` , ( ) => {
7575 const expectedLogFunc = ( ) => 'test' ;
76- utils . logger . setLogFunc ( expectedLogFunc ) ;
77- assert . equal ( utils . logger . logFunc , expectedLogFunc , `The log function was not set properly` ) ;
76+ logger . setLogFunc ( expectedLogFunc ) ;
77+ assert . equal ( logger . logFunc , expectedLogFunc , `The log function was not set properly` ) ;
7878 } ) ;
7979 it ( `Verify logger throws an error when setting an unknown log level` , ( ) => {
80- assert . throws ( ( ) => utils . logger . setLogLevel ( 0 ) , Error , `An error was not thrown when setting an unknown log level` ) ;
80+ assert . throws ( ( ) => logger . setLogLevel ( 0 ) , Error , `An error was not thrown when setting an unknown log level` ) ;
8181 } ) ;
8282} ) ;
0 commit comments