@@ -10,20 +10,19 @@ describe('Parser Test Suite', () => {
1010 describe ( 'It works for simple apps' , ( ) => {
1111 beforeAll ( ( ) => {
1212 // console.log('-----test 0----------')
13- file = path . join ( __dirname , '../test_cases/tc_0/index.js' ) ;
13+ file = path . join ( __dirname , '../../../../src/test/ test_cases/tc_0/index.js' ) ;
1414 parser = new Parser ( file ) ;
1515 tree = parser . parse ( ) ;
16- console . log ( 'tree' , tree ) ;
16+ // console.log('tree', tree);
1717 } ) ;
1818
1919 test ( 'Tree should not be undefined' , ( ) => {
2020 expect ( tree ) . toBeDefined ( ) ;
2121 expect ( typeof ( tree ) ) . toBe ( 'object' ) ;
2222 } ) ;
2323
24- test ( 'Parsed tree has a property called name with value index and one child with name App' , ( ) => {
24+ test ( 'Parsed tree has a property called name with value index, and a child with the name App' , ( ) => {
2525 expect ( tree ) . toHaveProperty ( 'name' , 'index' ) ;
26- // console.log('--------------index---------');
2726 expect ( tree . children [ 0 ] ) . toHaveProperty ( 'name' , 'App' ) ;
2827 } ) ;
2928 } ) ;
@@ -34,16 +33,44 @@ describe('Parser Test Suite', () => {
3433
3534 describe ( 'It checks for nested Children' , ( ) => {
3635 beforeEach ( ( ) => {
37- file = path . join ( __dirname , '../../../../test_cases/tc_1/index.js' ) ;
38- // file = path.join(__dirname, '../../../src/test/test_apps/test_0/index.js');
36+ file = path . join ( __dirname , '../../../../src/test/test_cases/tc_1/index.js' ) ;
3937 parser = new Parser ( file ) ;
38+ tree = parser . parse ( ) ;
39+ console . log ( 'tree 1' , tree ) ;
40+ } )
41+
42+ test ( 'Parsed tree should have a property called name with the value index, and one child with name App, which has its own child, Main' , ( ) => {
43+ expect ( tree ) . toHaveProperty ( 'name' , 'index' ) ;
44+ expect ( tree . children [ 0 ] ) . toHaveProperty ( 'name' , 'App' ) ;
45+ // console.log(tree.children[0].children);
46+ expect ( tree . children [ 0 ] . children [ 0 ] ) . toHaveProperty ( 'name' , 'Main' ) ;
4047 } )
4148
42- console . log ( 'inside Test 1' )
49+ test ( 'Parsed tree has correct amount of child components' , ( ) => {
50+ expect ( tree . children ) . toHaveLength ( 1 ) ;
51+ expect ( tree . children [ 0 ] . children ) . toHaveLength ( 1 ) ;
52+ } )
53+
54+ test ( 'Parsed tree depth is accurate' , ( ) => {
55+ expect ( tree ) . toHaveProperty ( 'depth' , 0 ) ;
56+ expect ( tree . children [ 0 ] ) . toHaveProperty ( 'depth' , 1 ) ;
57+ expect ( tree . children [ 0 ] . children [ 0 ] ) . toHaveProperty ( 'depth' , 2 ) ;
58+ } )
4359 } )
4460
61+ // TEST 2: THIRD PARTY, REACT ROUTER, DESTRUCTURED IMPORTS
62+ describe ( 'It works for third party, React Router, and destructured imports' , ( ) => {
63+ beforeAll ( ( ) => {
64+ file = path . join ( __dirname , '../../../../src/test/test_cases/tc_2/index.js' ) ;
65+ parser = new Parser ( file ) ;
66+ tree = parser . parse ( ) ;
67+ console . log ( tree ) ;
68+ } )
69+
70+
71+ } )
72+
4573
46-
4774 // TEST 6: BAD IMPORT OF APP2 FROM APP1 COMPONENT
4875 describe ( 'Catches bad imports' , ( ) => {
4976 beforeEach ( ( ) => {
@@ -76,6 +103,7 @@ describe('Parser Test Suite', () => {
76103 file = path . join ( __dirname , '../../../../src/test/test_cases/tc_11/index.js' ) ;
77104 parser = new Parser ( file ) ;
78105 tree = parser . parse ( ) ;
106+ // console.log('tree11', tree);
79107 } ) ;
80108
81109 test ( 'Tree should not be undefined' , ( ) => {
@@ -195,20 +223,14 @@ describe('Parser Test Suite', () => {
195223
196224
197225
198- // TEST 2: THIRD PARTY, REACT ROUTER, DESTRUCTURED IMPORTS
226+
199227// TEST 3: IDENTIFIES REDUX STORE CONNECTION
200228// TEST 4: ALIASED IMPORTS
201229// TEST 5: MISSING EXTENSIONS AND UNUSED IMPORTS
202- // TEST 6: BAD IMPORT OF APP2 FROM APP1 COMPONENT
203- // TEST 7: SYNTAX ERROR IN APP FILE CAUSES PARSER ERROR
230+
204231// TEST 8: MULTIPLE PROPS ON ONE COMPONENT
205232// TEST 9: FINDING DIFFERENT PROPS ACROSS TWO OR MORE IDENTICAL COMPONENTS
206- // TEST 10: CHECK CHILDREN WORKS AND COMPONENTS WORK
207- // TEST 11: PARSER DOESN'T BREAK UPON RECURSIVE COMPONENTS
208- // TEST 12: NEXT.JS APPS (pages version & app router version)
209- // TEST 13: Variable Declaration Imports and React.lazy Imports
210- // TEST 14: CHECK IF COMPONENT IS CLIENT OR SERVER (USING HOOKS & DIRECTIVES) => BOOLEAN (priority)
211-
233+
212234 // LOU is doing EXTENSION TEST in extension.test.ts
213235
214236} ) ;
0 commit comments