Skip to content

Commit df191fa

Browse files
finished tests 0-2
1 parent b9d518b commit df191fa

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

.DS_Store

0 Bytes
Binary file not shown.

src/test/suite/parser.test.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/test/test_cases/tc_2/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import React from "react";
22
import { render } from "react-dom";
3+
import { Switch, Route} from 'react-router-dom';
34

45

56
// TEST 2: THIRD PARTY, REACT ROUTER, DESTRUCTURED IMPORTS
67

78
render(
89
<div>
9-
10+
<Switch >
11+
<Route component={App}>
12+
</Route>
13+
</Switch>
1014
</div>, document.getElementById('root')
1115
);

0 commit comments

Comments
 (0)