Skip to content

Commit

Permalink
test: ✅ run export x from 'y' in js code
Browse files Browse the repository at this point in the history
  • Loading branch information
stormslowly committed Mar 22, 2023
1 parent 2b23b18 commit 9cb99d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
20 changes: 13 additions & 7 deletions __test__/export-declaration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,19 @@ const TEST_TABLE = [

// ts doesn't allow this
// in swc js, need to turn on this by
test.skip('export x from "a"', () => {
try {
const json = parseCode(`export x from "a"`);
} catch (e) {
console.log(e);
fail(e);
}
test('export x from "a"', () => {
const imps = parseCode(`export x from "a"`, 'x.js');
expect(imps).toEqual(
[{
"type": "ExportNamedDeclaration",
"specifiers": [{"exported": "x", "type": "ExportDefaultSpecifier"}],
"exportKind": "value",
"source": "a",
"start": expect.any(Number),
"end": expect.any(Number),
}]
)

})

test.skip('export type * from "a"', () => {
Expand Down
10 changes: 5 additions & 5 deletions __test__/performance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import {readFileSync} from 'fs'
import {join} from "path";
// @ts-ignore
import {parseFiles, parseFilesJsonStr} from "../index";

let files: string[] = [];

try {
files = readFileSync(join(__dirname, 'list.txt'), 'utf-8').trim().split('\n');
files = readFileSync(join(__dirname, 'list.txt'), 'utf-8').trim().split('\n')
} catch (e) {
}


if (files.length === 0) {
console.error('if you want to run performance test, put files list in __test__/list.txt')
console.error('a file path per line')
Expand All @@ -23,7 +23,7 @@ if (files.length === 0) {
const duration = Date.now() - start;

console.log(
`[JSON] parse ${files.length} files, cost ${duration}ms, average ${duration / files.length}ms per file`
`[JSONString] parse ${files.length} files, cost ${duration}ms, average ${duration / files.length}ms per file`
)
})

Expand All @@ -33,10 +33,10 @@ if (files.length === 0) {
const duration = Date.now() - start;

console.log(
`[Object] parse ${files.length} files, cost ${duration}ms, average ${duration / files.length}ms per file`
`[ Object ] parse ${files.length} files, cost ${duration}ms, average ${duration / files.length}ms per file`
)
})
}

it.skip('bypass jest error', () => {
it('bypass jest error', () => {
});

0 comments on commit 9cb99d4

Please sign in to comment.