Skip to content

Commit

Permalink
test: #28 parse tsx file error
Browse files Browse the repository at this point in the history
  • Loading branch information
sz-p committed May 6, 2022
1 parent 8b729ca commit 5804845
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"%DIR-PATH%\\src\\index.js": {
"absolutePath": "%DIR-PATH%\\src\\index.js",
"ancestors": [],
"children": [
{
"absolutePath": "%DIR-PATH%\\src\\tsx.tsx",
"ancestors": [
"%DIR-PATH%\\src\\index.js"
],
"extension": ".tsx",
"name": "tsx.tsx",
"relativePath": "\\src\\tsx.tsx",
"children": [
{
"absolutePath": "%DIR-PATH%\\src\\my.js",
"ancestors": [
"%DIR-PATH%\\src\\index.js",
"%DIR-PATH%\\src\\tsx.tsx"
],
"extension": ".js",
"name": "my.js",
"relativePath": "\\src\\my.js",
"children": [],
"fileDescription": {},
"type": "javascript",
"language": "javascript",
"analysed": true,
"lines": 1,
"functions": []
}
],
"fileDescription": {},
"type": "react_ts",
"language": "file"
}
],
"extension": ".js",
"name": "index.js",
"relativePath": "\\src\\index.js",
"fileDescription": {},
"type": "javascript",
"language": "javascript",
"analysed": true,
"lines": 2,
"functions": []
},
"%DIR-PATH%\\src\\tsx.tsx": {
"absolutePath": "%DIR-PATH%\\src\\tsx.tsx",
"ancestors": [
"%DIR-PATH%\\src\\index.js"
],
"extension": ".tsx",
"name": "tsx.tsx",
"relativePath": "\\src\\tsx.tsx",
"children": [
{
"absolutePath": "%DIR-PATH%\\src\\my.js",
"ancestors": [
"%DIR-PATH%\\src\\index.js",
"%DIR-PATH%\\src\\tsx.tsx"
],
"extension": ".js",
"name": "my.js",
"relativePath": "\\src\\my.js",
"children": [],
"fileDescription": {},
"type": "javascript",
"language": "javascript",
"analysed": true,
"lines": 1,
"functions": []
}
],
"fileDescription": {},
"type": "react_ts",
"language": "file"
},
"%DIR-PATH%\\src\\my.js": {
"absolutePath": "%DIR-PATH%\\src\\my.js",
"ancestors": [
"%DIR-PATH%\\src\\index.js",
"%DIR-PATH%\\src\\tsx.tsx"
],
"extension": ".js",
"name": "my.js",
"relativePath": "\\src\\my.js",
"children": [],
"fileDescription": {},
"type": "javascript",
"language": "javascript",
"analysed": true,
"lines": 1,
"functions": []
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"absolutePath": "%DIR-PATH%\\src\\index.js",
"ancestors": [],
"children": [
{
"absolutePath": "%DIR-PATH%\\src\\tsx.tsx",
"ancestors": [
"%DIR-PATH%\\src\\index.js"
],
"extension": ".tsx",
"name": "tsx.tsx",
"relativePath": "\\src\\tsx.tsx",
"children": [
{
"absolutePath": "%DIR-PATH%\\src\\my.js",
"ancestors": [
"%DIR-PATH%\\src\\index.js",
"%DIR-PATH%\\src\\tsx.tsx"
],
"extension": ".js",
"name": "my.js",
"relativePath": "\\src\\my.js",
"children": [],
"fileDescription": {},
"type": "javascript",
"language": "javascript",
"analysed": true,
"lines": 1,
"functions": []
}
],
"fileDescription": {},
"type": "react_ts",
"language": "file"
}
],
"extension": ".js",
"name": "index.js",
"relativePath": "\\src\\index.js",
"fileDescription": {},
"type": "javascript",
"language": "javascript",
"analysed": true,
"lines": 2,
"functions": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./tsx.tsx";
Empty file.
7 changes: 7 additions & 0 deletions tests/extensionTester/dependencyTester/tsx/files/src/tsx.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import my from './my'

function App(options) {
return <>hello world</>
}

export default App
49 changes: 49 additions & 0 deletions tests/extensionTester/dependencyTester/tsx/requireModule.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {
getDependencyTreeDataFromFile,
getDependencyTreeDataByCompute,
getWebViewDataByCompute,
getSavedDataFromFile,
getSavedDataByCompute,
getWebViewDataFromFile,
setDataToFile
} from "../utils";
import { expect } from 'chai';
const mainFilePath = "./src/index.js";
const {
dependencyTreeData,
dependencyNodesData,
folderPath,
} = getDependencyTreeDataFromFile("tsx");
// const folderPath = path.join(__dirname, `./files`)
const { dependencyTree, dependencyNodes } = getDependencyTreeDataByCompute(
folderPath,
mainFilePath
);
const savedDataFromFile = getSavedDataFromFile("tsx");
const savedDataByCompute = getSavedDataByCompute(
"tsx",
folderPath,
mainFilePath
);
const readData = getWebViewDataByCompute("tsx", folderPath);
const webViewData = getWebViewDataFromFile("tsx");
describe("dependencyTree(tsx): get dependencyTree data", function () {
it("dependencyNodesData", function () {
expect(dependencyNodesData.length).to.equal(dependencyNodes.length);
});
it("dependencyTreeData", function () {
expect(dependencyTreeData.length).to.equal(dependencyTree.length);
});
});

describe("dependencyTree(tsx): get saved data", function () {
it("jsonString", function () {
expect(savedDataFromFile.length).to.equal(savedDataByCompute.length);
});
});

describe("dependencyTree(tsx): get webView data", function () {
it("dependencyTreeData", function () {
expect(readData.length).to.equal(webViewData.length);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"dependencyTree":{"name":"index.js","ancestors":[],"fileID":"43351ecb56f3a7e10f80143f717fe4ea","nodeID":"43351ecb56f3a7e10f80143f717fe4ea","children":[{"name":"tsx.tsx","ancestors":["43351ecb56f3a7e10f80143f717fe4ea"],"fileID":"da0acda11625edcc51dde30cd2802fc2","nodeID":"9fe3fcd7c02b5894297ff213d90e989c","children":[{"name":"my.js","ancestors":["43351ecb56f3a7e10f80143f717fe4ea","da0acda11625edcc51dde30cd2802fc2"],"fileID":"6ac94e8f6bdf69e3667d5a6106a7c234","nodeID":"15ca17f27495df1a606c46c980b8cd75","children":[]}]}]},"dependencyNodes":{"43351ecb56f3a7e10f80143f717fe4ea":{"fileID":"43351ecb56f3a7e10f80143f717fe4ea","name":"index.js","type":"javascript","extension":".js","language":"javascript","lines":2,"analysed":true,"relativePath":"\\src\\index.js","fileDescription":{},"functions":[],"children":["da0acda11625edcc51dde30cd2802fc2"]},"da0acda11625edcc51dde30cd2802fc2":{"fileID":"da0acda11625edcc51dde30cd2802fc2","name":"tsx.tsx","type":"react_ts","extension":".tsx","language":"file","relativePath":"\\src\\tsx.tsx","fileDescription":{},"children":["6ac94e8f6bdf69e3667d5a6106a7c234"]},"6ac94e8f6bdf69e3667d5a6106a7c234":{"fileID":"6ac94e8f6bdf69e3667d5a6106a7c234","name":"my.js","type":"javascript","extension":".js","language":"javascript","lines":1,"analysed":true,"relativePath":"\\src\\my.js","fileDescription":{},"functions":[],"children":[]}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "index.js",
"fileID": "43351ecb56f3a7e10f80143f717fe4ea",
"nodeID": "43351ecb56f3a7e10f80143f717fe4ea",
"ancestors": [],
"fileDescription": {},
"type": "javascript",
"language": "javascript",
"lines": 2,
"analysed": true,
"functions": [],
"extension": ".js",
"absolutePath": "%DIR-PATH%\\src\\index.js",
"relativePath": "\\src\\index.js",
"children": [
{
"name": "tsx.tsx",
"fileID": "da0acda11625edcc51dde30cd2802fc2",
"nodeID": "9fe3fcd7c02b5894297ff213d90e989c",
"ancestors": [
"43351ecb56f3a7e10f80143f717fe4ea"
],
"fileDescription": {},
"type": "react_ts",
"language": "file",
"extension": ".tsx",
"absolutePath": "%DIR-PATH%\\src\\tsx.tsx",
"relativePath": "\\src\\tsx.tsx",
"children": [
{
"name": "my.js",
"fileID": "6ac94e8f6bdf69e3667d5a6106a7c234",
"nodeID": "15ca17f27495df1a606c46c980b8cd75",
"ancestors": [
"43351ecb56f3a7e10f80143f717fe4ea",
"da0acda11625edcc51dde30cd2802fc2"
],
"fileDescription": {},
"type": "javascript",
"language": "javascript",
"lines": 1,
"analysed": true,
"functions": [],
"extension": ".js",
"absolutePath": "%DIR-PATH%\\src\\my.js",
"relativePath": "\\src\\my.js",
"children": []
}
]
}
]
}

0 comments on commit 5804845

Please sign in to comment.