Skip to content

Commit 809753e

Browse files
committed
updated parser.test.ts file
1 parent 54d06ad commit 809753e

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

src/parser.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ export class Parser {
305305
}
306306
};
307307

308+
// if statement to first check if component has a directive that is strictly equal to 'use client' or 'use server'
309+
// if there is no directive, continue down the chain of logic below
310+
308311
const bodyCallee = body.filter((item) => item.type === 'VariableDeclaration');
309312
if (bodyCallee.length === 0) return false;
310313

src/test/suite/extension.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import * as vscode from 'vscode'
66
// we can either use test() or it() -- matter of style for team/project convention
77

88
describe('Extension Test Suite', () => {
9-
// beforeEach(() => {
10-
// vscode.window.showInformationMessage('Start all tests.');
11-
// });
129

1310
it('Sample test', () => {
1411
expect([1, 2, 3].indexOf(5)).toBe(-1);

src/test/suite/parser.test.ts

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,64 +9,62 @@ import * as vscode from 'vscode'
99
// const myExtension = require('../extension');
1010

1111
describe('Parser Test Suite', () => {
12-
// beforeEach(() => {
13-
// vscode.window.showInformationMessage('Start all tests.');
14-
// });
15-
1612
let parser, tree, file;
1713

1814
// UNPARSED TREE TEST
1915
describe('It initializes correctly', () => {
2016
beforeEach(() => {
2117
// declare var and assign it to a test file and make new instance of Parser
22-
// both of the paths below work
23-
// file = path.join(__dirname, '../test_cases/tc_0/index.js');
24-
file = path.join(__dirname, '../../../src/test/test_apps/test_0/index.js');
18+
file = path.join(__dirname, '../test_cases/tc_0/index.js');
19+
// file = path.join(__dirname, '../../../src/test/test_apps/test_0/index.js');
2520
parser = new Parser(file);
2621
});
2722

2823
test('It instantiates an object for the parser class', () => {
2924
expect((parser)).toBeInstanceOf(Parser);
30-
// assert.typeOf(parser, 'object', 'Value of new instance should be an object');
31-
// expect(parser).to.be.an('object');
3225
});
3326

3427
test('It begins with a suitable entry file and a tree that is not yet defined', () => {
3528
expect(parser.entryFile).toEqual(file);
3629
expect(tree).toBeUndefined();
37-
// below is my code
38-
// assert.strictEqual(parser.entryFile, file, 'These files are strictly equal');
39-
// assert.isUndefined(tree, 'Tree is defined');
4030
});
4131
});
4232

43-
// TEST ?: UNPARSED TREE TEST FOR REACT 18(createRoot)
44-
4533
// TEST 0: ONE CHILD
46-
// describe('It works for simple apps', () => {
47-
// before(() => {
48-
// file = path.join(__dirname, '');
49-
// parser = new Parser(file);
50-
// tree = parser.parse();
51-
// });
34+
describe('It works for simple apps', () => {
35+
before(() => {
36+
file = path.join(__dirname, '');
37+
parser = new Parser(file);
38+
tree = parser.parse();
39+
});
40+
41+
test('It returns an defined object tree when parsed', () => {
42+
expect(tree).toBeDefined();
43+
//expect(tree).toMatchObject()
44+
});
5245

53-
// test('It returns an defined object tree when parsed', () => {
54-
// assert.typeOf(tree, 'object', 'Value of parse() on new instance should be an object');
55-
// });
56-
// });
46+
test('Parsed tree has a property called name with value index and one child with name App', () => {
47+
48+
});
49+
});
5750

58-
// TEST 0.5: CHECK IF COMPONENT IS CLIENT OR SERVER (USING HOOKS) => RENDERS A CERTAIN COLOR
5951
// TEST 1: NESTED CHILDREN
6052
// TEST 2: THIRD PARTY, REACT ROUTER, DESTRUCTURED IMPORTS
6153
// TEST 3: IDENTIFIES REDUX STORE CONNECTION
6254
// TEST 4: ALIASED IMPORTS
6355
// TEST 5: MISSING EXTENSIONS AND UNUSED IMPORTS
56+
57+
// ashley
6458
// TEST 6: BAD IMPORT OF APP2 FROM APP1 COMPONENT
6559
// TEST 7: SYNTAX ERROR IN APP FILE CAUSES PARSER ERROR
6660
// TEST 8: MULTIPLE PROPS ON ONE COMPONENT
6761
// TEST 9: FINDING DIFFERENT PROPS ACROSS TWO OR MORE IDENTICAL COMPONENTS
62+
6863
// TEST 10: CHECK CHILDREN WORKS AND COMPONENTS WORK
6964
// TEST 11: PARSER DOESN'T BREAK UPON RECURSIVE COMPONENTS
70-
// TEST 12: NEXT.JS APPS (pages & app router)
71-
// TEST 13: Variable Declaration Imports and React.lazy Imports
72-
});
65+
// TEST 12: NEXT.JS APPS (pages version & app router version)
66+
// TEST 13: Variable Declaration Imports and React.lazy Imports
67+
// TEST 14: CHECK IF COMPONENT IS CLIENT OR SERVER (USING HOOKS) => RENDERS A CERTAIN COLOR (priority)
68+
69+
// LOU - EXTENSION TEST
70+
});

0 commit comments

Comments
 (0)