forked from docsifyjs/docsify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.test.js
More file actions
64 lines (50 loc) 路 1.45 KB
/
Copy pathbase.test.js
File metadata and controls
64 lines (50 loc) 路 1.45 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* eslint-disable no-global-assign */
require = require('esm')(
module /* , options */
); /* eslint-disable-line no-global-assign */
const { expect } = require('chai');
const { History } = require('../../src/core/router/history/base');
class MockHistory extends History {
parse(path) {
return { path };
}
}
describe('router/history/base', function() {
describe('relativePath true', function() {
let history;
beforeEach(function() {
history = new MockHistory({ relativePath: true });
});
it('toURL', function() {
// WHEN
const url = history.toURL('guide.md', {}, '/zh-ch/');
// THEN
expect(url).equal('/zh-ch/guide');
});
it('toURL with double dot', function() {
// WHEN
const url = history.toURL('../README.md', {}, '/zh-ch/');
// THEN
expect(url).equal('/README');
});
it('toURL child path', function() {
// WHEN
const url = history.toURL('config/example.md', {}, '/zh-ch/');
// THEN
expect(url).equal('/zh-ch/config/example');
});
it('toURL absolute path', function() {
// WHEN
const url = history.toURL('/README', {}, '/zh-ch/');
// THEN
expect(url).equal('/README');
});
});
it('toURL without relative path', function() {
const history = new MockHistory({ relativePath: false });
// WHEN
const url = history.toURL('README', {}, '/zh-ch/');
// THEN
expect(url).equal('/README');
});
});