@@ -13,7 +13,6 @@ describe('Parser Test Suite', () => {
1313 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);
1716 } ) ;
1817
1918 test ( 'Tree should not be undefined' , ( ) => {
@@ -36,7 +35,6 @@ describe('Parser Test Suite', () => {
3635 file = path . join ( __dirname , '../../../../src/test/test_cases/tc_1/index.js' ) ;
3736 parser = new Parser ( file ) ;
3837 tree = parser . parse ( ) ;
39- console . log ( 'tree 1' , tree ) ;
4038 } )
4139
4240 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' , ( ) => {
@@ -64,9 +62,31 @@ describe('Parser Test Suite', () => {
6462 file = path . join ( __dirname , '../../../../src/test/test_cases/tc_2/index.js' ) ;
6563 parser = new Parser ( file ) ;
6664 tree = parser . parse ( ) ;
67- console . log ( tree ) ;
6865 } )
6966
67+ test ( 'Should parse destructured and third party imports' , ( ) => {
68+ expect ( tree ) . toHaveProperty ( 'thirdParty' , false ) ;
69+ expect ( tree . children [ 0 ] ) . toHaveProperty ( 'thirdParty' , true ) ;
70+ expect ( tree . children [ 1 ] ) . toHaveProperty ( 'thirdParty' , true ) ;
71+
72+ try {
73+ expect ( tree . children [ 0 ] . name ) . toContain ( 'Switch' )
74+ } catch {
75+ expect ( tree . children [ 0 ] . name ) . toContain ( 'Route' )
76+
77+ }
78+ try {
79+ expect ( tree . children [ 1 ] . name ) . toContain ( 'Switch' )
80+ } catch {
81+ expect ( tree . children [ 1 ] . name ) . toContain ( 'Route' )
82+
83+ }
84+ } )
85+
86+ test ( 'third party should be reactRouter' , ( ) => {
87+ expect ( tree . children [ 0 ] ) . toHaveProperty ( 'reactRouter' , true ) ;
88+ expect ( tree . children [ 1 ] ) . toHaveProperty ( 'reactRouter' , true ) ;
89+ } )
7090
7191 } )
7292
0 commit comments