mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
* UPDATE .eslintrc * UPDATE lint task * FIX lint errors * CLEANUP * FIX no-eq-null warning * FIX many jsdoc warnings * FIX jsdoc issues * FIX jsdoc warnings * FIX jsdoc * FIX eqeq and no-eq-null * ADD lint to travis * UPDATE test env for eslint
62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
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 () {
|
|
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')
|
|
})
|
|
})
|