Skip to content

Commit 8accca3

Browse files
committed
test: add wildcard and js tests
1 parent aae6399 commit 8accca3

File tree

7 files changed

+13
-4
lines changed

7 files changed

+13
-4
lines changed

test/bar/foo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const bar = 'foo';

test/foo/bar.d.ts

Whitespace-only changes.

test/foo/bar.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/foo/bar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const foo = 'bar';

test/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ const { resolveTypescriptPaths } = require('../dist');
44

55
const plugin = resolveTypescriptPaths({ tsConfigPath: resolve(__dirname, 'tsconfig.json') });
66

7-
const resolved = plugin.resolveId('@foobar', '');
7+
const resolvedBasic = plugin.resolveId('@foobar', '');
8+
const resolvedWildcard = plugin.resolveId('@bar/foo', '');
9+
const resolvedJs = plugin.resolveId('@js', '');
810

911
try {
10-
strictEqual(resolved, 'test/foo/bar.js');
12+
strictEqual(plugin.resolveId('@asdf', ''), null);
13+
strictEqual(resolvedBasic, 'test/foo/bar.ts');
14+
strictEqual(resolvedWildcard, 'test/bar/foo.ts');
15+
strictEqual(resolvedJs, 'test/js/index.js');
1116
console.log('PASSED');
1217
} catch (error) {
1318
throw error;

test/js/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = 'js';

test/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"compilerOptions": {
33
"baseUrl": "test",
44
"paths": {
5-
"@foobar": ["foo/bar"]
5+
"@foobar": ["foo/bar"],
6+
"@bar/*": ["bar/*"],
7+
"@js": ["js"]
68
}
79
}
810
}

0 commit comments

Comments
 (0)