Skip to content

Commit 146e896

Browse files
first working test suite
1 parent ecc047b commit 146e896

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

.DS_Store

6 KB
Binary file not shown.

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"no-this-before-super": "warn",
1919
"no-undef": "warn",
2020
"no-unreachable": "warn",
21-
"no-unused-vars": "warn",
21+
"no-unused-vars": "off",
2222
"constructor-super": "warn",
2323
"valid-typeof": "warn"
2424
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"scripts": {
7171
"lint": "eslint .",
7272
"pretest": "npm run lint",
73-
"test": "node ./build/src/test/runTest.js",
73+
"test": "npx tsc ; node ./build/src/test/runTest.js",
7474
"dev": "webpack --watch",
7575
"webpack": "webpack"
7676
},

src/test/suite/parser.test.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// import * as assert from 'assert' -- this one is from node
22
import { Parser } from '../../parser';
33
import * as path from 'path';
4-
import { beforeEach, expect, test } from '@jest/globals';
4+
import { beforeEach, beforeAll, expect, test } from '@jest/globals';
55

66
// You can import and use all API from the 'vscode' module
77
// as well as import your extension to test it
@@ -15,8 +15,7 @@ describe('Parser Test Suite', () => {
1515
describe('It initializes correctly', () => {
1616
beforeEach(() => {
1717
// declare var and assign it to a test file and make new instance of Parser
18-
file = path.join(__dirname, '../test_cases/tc_0/index.js');
19-
// file = path.join(__dirname, '../../../src/test/test_apps/test_0/index.js');
18+
file = path.join(__dirname, '../../../../src/test/test_cases/tc_0/index.js');
2019
parser = new Parser(file);
2120
});
2221

@@ -31,30 +30,32 @@ describe('Parser Test Suite', () => {
3130
});
3231

3332
// TEST 0: ONE CHILD
34-
it('It works for simple apps', () => {
33+
describe('It works for simple apps', () => {
3534
beforeAll(() => {
36-
console.log('-----test 0----------')
37-
file = path.join(__dirname, '../test_cases/tc_0/index.js');
35+
// console.log('-----test 0----------')
36+
file = path.join(__dirname, '../../../../src/test/test_cases/tc_0/index.js');
3837
parser = new Parser(file);
3938
tree = parser.parse();
39+
console.log('tree', tree);
4040
});
4141

4242
test('It returns an defined object tree when parsed', () => {
4343
expect(tree).toBeDefined();
44-
//expect(tree).toMatchObject()
44+
expect(typeof(tree)).toBe('object');
4545
});
4646

4747
test('Parsed tree has a property called name with value index and one child with name App', () => {
48-
expect(tree).toHaveProperty('index');
49-
console.log('--------------index---------');
48+
expect(tree).toHaveProperty('name', 'index');
49+
// console.log('--------------index---------');
50+
expect(tree.children[0]).toHaveProperty('name', 'App');
5051
});
5152
});
5253

5354
// TEST 1: NESTED CHILDREN
5455

5556
describe('It checks for nested Children', () => {
5657
beforeEach(() => {
57-
file = path.join(__dirname, '../test_cases/tc_1/index.js');
58+
file = path.join(__dirname, '../../../../test_cases/tc_1/index.js');
5859
// file = path.join(__dirname, '../../../src/test/test_apps/test_0/index.js');
5960
parser = new Parser(file);
6061
})

src/test/test_cases/tc_0/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import React from 'react';
1111
import { createRoot } from 'react-dom/client';
12-
import App from './components/App.jsx';
12+
import App from './component/App';
1313

1414
const root = createRoot(document.getElementById('root'));
1515
root.render(<App />);

src/test/test_cases/tc_2/index.js

Whitespace-only changes.

0 commit comments

Comments
 (0)