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 @@ -47,6 +47,20 @@ describe('Parser Test Suite', () => {
4747 // });
4848 } ) ;
4949
50+ // TEST 7: SYNTAX ERROR IN APP FILE CAUSES PARSER ERROR
51+ describe ( 'Parser should not work for components with syntax errors in the code' , ( ) => {
52+ beforeEach ( ( ) => {
53+ file = path . join ( __dirname , '../../../../src/test/test_cases/tc_7/index.js' ) ;
54+ parser = new Parser ( file ) ;
55+ tree = parser . parse ( ) ;
56+ } ) ;
57+ test ( "Parser stops parsing when there is a syntax error in a component" , ( ) => {
58+ expect ( tree . children [ 0 ] . name ) . toBe ( 'App' ) ;
59+ expect ( tree . children [ 0 ] . error ) . not . toBeUndefined ;
60+ expect ( ( tree . children [ 0 ] . children ) . length ) . toBe ( 0 ) ;
61+ } ) ;
62+ } )
63+
5064 // these are the 14 tests we need to test for
5165
5266 // 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