Skip to content

Commit a73545f

Browse files
committed
add basic test
1 parent fa9d866 commit a73545f

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"types": "dist/index.d.ts",
77
"scripts": {
88
"build": "tsc",
9-
"test": "echo \"Error: no test specified\" && exit 1"
9+
"test": "npm run build && node test"
1010
},
1111
"author": "Simon Haenisch (https://github.com/simonhaenisch)",
1212
"repository": "simonhaenisch/rollup-plugin-typescript-paths",

test/foo/bar.js

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

test/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const { strictEqual } = require('assert');
2+
const { resolve } = require('path');
3+
const { resolveTypescriptPaths } = require('../dist');
4+
5+
const plugin = resolveTypescriptPaths({ tsConfigPath: resolve(__dirname, 'tsconfig.json') });
6+
7+
const resolved = plugin.resolveId('@foobar', '');
8+
9+
try {
10+
strictEqual(resolved, 'test/foo/bar.js');
11+
console.log('PASSED');
12+
} catch (error) {
13+
throw error;
14+
}

test/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": "test",
4+
"paths": {
5+
"@foobar": ["foo/bar"]
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)