Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit d2b1896

Browse files
crisptrutskiguybedford
authored andcommitted
Test coverage for System.paths priorities
1 parent 7f77b6a commit d2b1896

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/system.normalize.spec.js

+19
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ describe('System', function () {
6666

6767
beforeEach(function () {
6868
System.baseURL = 'http://example.org/a/';
69+
// required to stop paths leaking between tests (wrecks order for example)
70+
delete System.paths['path/*'];
71+
delete System.paths['path/specific/*'];
72+
delete System.paths['path/best/*'];
6973
});
7074

7175
it('should resolve paths', function () {
@@ -81,5 +85,20 @@ describe('System', function () {
8185
.to.equal('http://example.org/test/test.js');
8286
});
8387

88+
it('should show precedence to longer wilcard paths', function () {
89+
// most specific path first to illustrate not last-case-wins
90+
System.paths['path/specific/*'] = '/best/*.js';
91+
System.paths['path/*'] = '/test/*.js';
92+
expect(System.locate({name: 'path/specific/test'}))
93+
.to.equal('http://example.org/best/test.js');
94+
});
95+
96+
it('should show precedence to last wilcard path in case of tie', function () {
97+
System.paths['path/*/test'] = '/test/*.js';
98+
System.paths['path/best/*'] = '/best/*.js';
99+
expect(System.locate({name: 'path/best/test'}))
100+
.to.equal('http://example.org/best/test.js');
101+
});
102+
84103
});
85104
});

0 commit comments

Comments
 (0)