-
Notifications
You must be signed in to change notification settings - Fork 8
/
resolve.test.ts
34 lines (28 loc) · 1.1 KB
/
resolve.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { strict as assert } from 'assert';
import resolver from '../src/resolve';
describe('resolve', () => {
it('unresolved without sourceRoot', () => {
const resolve = resolver(undefined, undefined);
assert.equal(resolve('input.js'), 'input.js');
});
it('relative to mapUrl', () => {
const resolve = resolver('foo/script.js.map', undefined);
assert.equal(resolve('input.js'), 'foo/input.js');
});
it('relative to sourceRoot', () => {
const resolve = resolver(undefined, 'foo');
assert.equal(resolve('input.js'), 'foo/input.js');
});
it('relative to mapUrl then sourceRoot', () => {
const resolve = resolver('foo/script.js.map', 'bar');
assert.equal(resolve('input.js'), 'foo/bar/input.js');
});
it('prepends sourceRoot to source before resolving', () => {
const resolve = resolver('foo/script.js.map', 'bar');
assert.equal(resolve('/input.js'), 'foo/bar/input.js');
});
it('skips undefined sourceRoot before resolving', () => {
const resolve = resolver('foo/script.js.map', undefined);
assert.equal(resolve('/input.js'), '/input.js');
});
});