-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sylvain Brocard
committed
Mar 25, 2019
1 parent
31654f1
commit ca8ae50
Showing
3 changed files
with
95 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* eslint-env node, chai, mocha */ | ||
require = require('esm')(module/*, options*/) | ||
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 () { | ||
var 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') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* eslint-env node, chai, mocha */ | ||
require = require('esm')(module/*, options*/) | ||
const {expect} = require('chai') | ||
const {resolvePath} = require('../../src/core/router/util') | ||
|
||
describe('router/util', function () { | ||
it('resolvePath', async function () { | ||
// WHEN | ||
const result = resolvePath('hello.md') | ||
|
||
// THEN | ||
expect(result).equal('/hello.md') | ||
}) | ||
|
||
it('resolvePath with dot', async function () { | ||
// WHEN | ||
const result = resolvePath('./hello.md') | ||
|
||
// THEN | ||
expect(result).equal('/hello.md') | ||
}) | ||
|
||
it('resolvePath with two dots', async function () { | ||
// WHEN | ||
const result = resolvePath('test/../hello.md') | ||
|
||
// THEN | ||
expect(result).equal('/hello.md') | ||
}) | ||
}) |