|
1 | 1 | import { Parser } from '../../parser'; |
2 | 2 | import * as path from 'path'; |
3 | | -import { beforeAll, expect, test } from '@jest/globals'; |
| 3 | +import { beforeAll, beforeEach, expect, test } from '@jest/globals'; |
4 | 4 |
|
5 | 5 | describe('Parser Test Suite', () => { |
6 | 6 | let parser, tree, file; |
| 7 | + const fs = require('fs'); |
| 8 | + |
| 9 | + // TEST 6: BAD IMPORT OF APP2 FROM APP1 COMPONENT |
| 10 | + describe('Catches bad imports', () => { |
| 11 | + beforeEach(() => { |
| 12 | + file = path.join(__dirname, '../../../../src/test/test_cases/tc_6/component/App.jsx'); |
| 13 | + parser = new Parser(file); |
| 14 | + tree = parser.parse(); |
| 15 | + }); |
| 16 | + |
| 17 | + test("Child component with bad file path does not show up on the node tree", () => { |
| 18 | + expect(tree.children.length).toBe(0); |
| 19 | + }); |
| 20 | + }); |
| 21 | + |
| 22 | + // TEST 7: SYNTAX ERROR IN APP FILE CAUSES PARSER ERROR |
| 23 | + describe('Parser should not work for components with syntax errors in the code', () => { |
| 24 | + beforeEach(() => { |
| 25 | + file = path.join(__dirname, '../../../../src/test/test_cases/tc_7/index.js'); |
| 26 | + parser = new Parser(file); |
| 27 | + tree = parser.parse(); |
| 28 | + }); |
| 29 | + |
| 30 | + test("Parser stops parsing when there is a syntax error in a component", () => { |
| 31 | + expect(tree.children.length).toBe(0); |
| 32 | + }); |
| 33 | + }); |
7 | 34 |
|
8 | 35 | // TEST 11: PARSER DOESN'T BREAK UPON RECURSIVE COMPONENTS |
9 | 36 | describe('It should render the second call of mutually recursive components, but no further', () => { |
@@ -127,4 +154,24 @@ describe('Parser Test Suite', () => { |
127 | 154 | expect(tree.children[0].children[6]).toHaveProperty('isClientComponent', false); |
128 | 155 | }); |
129 | 156 | }); |
| 157 | + |
| 158 | + // these are the 14 tests we need to test for |
| 159 | + |
| 160 | + // TEST 1: NESTED CHILDREN |
| 161 | + // TEST 2: THIRD PARTY, REACT ROUTER, DESTRUCTURED IMPORTS |
| 162 | + // TEST 3: IDENTIFIES REDUX STORE CONNECTION |
| 163 | + // TEST 4: ALIASED IMPORTS |
| 164 | + // TEST 5: MISSING EXTENSIONS AND UNUSED IMPORTS |
| 165 | + // TEST 6: BAD IMPORT OF APP2 FROM APP1 COMPONENT |
| 166 | + // TEST 7: SYNTAX ERROR IN APP FILE CAUSES PARSER ERROR |
| 167 | + // TEST 8: MULTIPLE PROPS ON ONE COMPONENT |
| 168 | + // TEST 9: FINDING DIFFERENT PROPS ACROSS TWO OR MORE IDENTICAL COMPONENTS |
| 169 | + // TEST 10: CHECK CHILDREN WORKS AND COMPONENTS WORK |
| 170 | + // TEST 11: PARSER DOESN'T BREAK UPON RECURSIVE COMPONENTS |
| 171 | + // TEST 12: NEXT.JS APPS (pages version & app router version) |
| 172 | + // TEST 13: Variable Declaration Imports and React.lazy Imports |
| 173 | + // TEST 14: CHECK IF COMPONENT IS CLIENT OR SERVER (USING HOOKS & DIRECTIVES) => BOOLEAN (priority) |
| 174 | + |
| 175 | + // LOU is doing EXTENSION TEST in extension.test.ts |
| 176 | + |
130 | 177 | }); |
0 commit comments