Skip to content

Commit 2209927

Browse files
committed
Merge branch 'dev' into AL/client-conditionals
2 parents ece43e0 + fb4d211 commit 2209927

File tree

11 files changed

+160
-41
lines changed

11 files changed

+160
-41
lines changed

media/RL(Final).png

301 KB
Loading

package-lock.json

Lines changed: 46 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
{
5151
"id": "react-labyrinth",
5252
"title": "React Labyrinth",
53-
"icon": "/media/test1.svg"
53+
"icon": "/media/RL(Final).png"
5454
}
5555
]
5656
},
@@ -100,7 +100,7 @@
100100
},
101101
"dependencies": {
102102
"@babel/core": "^7.23.3",
103-
"@babel/parser": "^7.23.4",
103+
"@babel/parser": "^7.23.9",
104104
"@babel/preset-env": "^7.23.3",
105105
"@babel/preset-react": "^7.23.3",
106106
"babel": "^6.23.0",

src/panel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function createPanel(context: vscode.ExtensionContext, data: Tree, column
1818
);
1919

2020
// Set the icon logo of extension webview
21-
panel.iconPath = vscode.Uri.joinPath(context.extensionUri, 'media', 'favicon.ico');
21+
panel.iconPath = vscode.Uri.joinPath(context.extensionUri, 'media', 'RL(Final).png');
2222

2323
// Set URI to be the path to bundle
2424
const bundlePath: vscode.Uri = vscode.Uri.joinPath(context.extensionUri, 'build', 'bundle.js');

src/test/suite/parser.test.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
import { Parser } from '../../parser';
22
import * as path from 'path';
3-
import { beforeAll, expect, test } from '@jest/globals';
3+
import { beforeAll, beforeEach, expect, test } from '@jest/globals';
44

55
describe('Parser Test Suite', () => {
66
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+
});
734

835
// TEST 11: PARSER DOESN'T BREAK UPON RECURSIVE COMPONENTS
936
describe('It should render the second call of mutually recursive components, but no further', () => {
@@ -127,4 +154,24 @@ describe('Parser Test Suite', () => {
127154
expect(tree.children[0].children[6]).toHaveProperty('isClientComponent', false);
128155
});
129156
});
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+
130177
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from "react";
2+
import anotherApp from "./anotherApp"; // this is purposefully the wrong file path for anotherApp
3+
4+
const App = () => {
5+
return (
6+
<div>
7+
<p>Hello from App.jsx</p>
8+
<anotherApp />
9+
</div>
10+
)
11+
};
12+
13+
export default App;

src/test/test_cases/tc_6/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// !TEST 6: BAD IMPORT OF APP2 FROM APP1 COMPONENT
2+
import React from 'react';
3+
import { createRoot } from 'react-dom/client';
4+
import App from './components/App.jsx';
5+
6+
// tests whether the parser still works when a component is given the wrong File path
7+
8+
const root = createRoot(document.getElementById('root'));
9+
root.render(<App />);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from "react";
2+
3+
export const anotherApp = () => {
4+
return (
5+
<div>
6+
<p>Greetings from inside anotherApp</p>
7+
</div>
8+
)
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
}

0 commit comments

Comments
 (0)