File tree Expand file tree Collapse file tree 4 files changed +46
-0
lines changed
Expand file tree Collapse file tree 4 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,20 @@ describe('Parser Test Suite', () => {
6464 } )
6565 } )
6666
67+ // TEST 7: SYNTAX ERROR IN APP FILE CAUSES PARSER ERROR
68+ describe ( 'Parser should not work for components with syntax errors in the code' , ( ) => {
69+ beforeEach ( ( ) => {
70+ file = path . join ( __dirname , '../../../../src/test/test_cases/tc_7/index.js' ) ;
71+ parser = new Parser ( file ) ;
72+ tree = parser . parse ( ) ;
73+ } ) ;
74+ test ( "Parser stops parsing when there is a syntax error in a component" , ( ) => {
75+ expect ( tree . children [ 0 ] . name ) . toBe ( 'App' ) ;
76+ expect ( tree . children [ 0 ] . error ) . not . toBeUndefined ;
77+ expect ( ( tree . children [ 0 ] . children ) . length ) . toBe ( 0 ) ;
78+ } ) ;
79+ } )
80+
6781 // these are the 14 tests we need to test for
6882
6983 // TEST 1: NESTED CHILDREN
Original file line number Diff line number Diff line change 1+ import React , { Component } from 'react' ;
2+ import ChildApp from './ChildApp' ;
3+
4+ export const App = ( ) => {
5+ this should not work when given to the parser
6+ return (
7+ < div >
8+ < p > Syntax Error</ p >
9+ < ChildApp />
10+ </ div >
11+ )
12+
13+ }
Original file line number Diff line number Diff line change 1+ // this component will not show up in the children of App due to App's syntax error
2+ import React , { Component } from 'react' ;
3+
4+ export const ChildApp = ( ) => {
5+ return (
6+ < div >
7+ < p > Child of App with Syntax Error</ p >
8+ </ div >
9+ )
10+
11+ }
Original file line number Diff line number Diff line change 1+ //! TEST 7: SYNTAX ERROR IN APP FILE CAUSES PARSER ERROR
2+
3+ import React from 'react' ;
4+ import { createRoot } from 'react-dom/client' ;
5+ import App from './components/App.jsx' ;
6+
7+ const root = createRoot ( document . getElementById ( 'root' ) ) ;
8+ root . render ( < App /> ) ;
You can’t perform that action at this time.
0 commit comments