mirror of https://github.com/vuejs/vitepress
test: add unit test setup (#138)
parent
fdd498be70
commit
8735fc3096
@ -0,0 +1,22 @@
|
|||||||
|
import * as Utils from 'client/theme-default/utils'
|
||||||
|
|
||||||
|
describe('client/theme-default/utils', () => {
|
||||||
|
describe('ensureStartingSlash', () => {
|
||||||
|
it('should add slash to the beginning of the given path', () => {
|
||||||
|
expect(Utils.ensureStartingSlash('path')).toBe('/path')
|
||||||
|
expect(Utils.ensureStartingSlash('path/nested')).toBe('/path/nested')
|
||||||
|
expect(Utils.ensureStartingSlash('/path')).toBe('/path')
|
||||||
|
expect(Utils.ensureStartingSlash('/path/nested')).toBe('/path/nested')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('ensureEndingSlash', () => {
|
||||||
|
it('should add slash to the end of the given path', () => {
|
||||||
|
expect(Utils.ensureEndingSlash('path')).toBe('path/')
|
||||||
|
expect(Utils.ensureEndingSlash('path/nested')).toBe('path/nested/')
|
||||||
|
expect(Utils.ensureEndingSlash('path/')).toBe('path/')
|
||||||
|
expect(Utils.ensureEndingSlash('path/nested/')).toBe('path/nested/')
|
||||||
|
expect(Utils.ensureEndingSlash('path/page.html')).toBe('path/page.html')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
preset: 'ts-jest',
|
||||||
|
rootDir: __dirname,
|
||||||
|
moduleNameMapper: {
|
||||||
|
'^src/(.*)$': '<rootDir>/src/$1',
|
||||||
|
'^client/(.*)$': '<rootDir>/src/client/$1',
|
||||||
|
'^node/(.*)$': '<rootDir>/src/node/$1',
|
||||||
|
'^shared/(.*)$': '<rootDir>/src/shared/$1',
|
||||||
|
'^tests/(.*)$': '<rootDir>/__tests__/$1'
|
||||||
|
},
|
||||||
|
testMatch: ['<rootDir>/__tests__/**/*.spec.ts'],
|
||||||
|
testPathIgnorePatterns: ['/node_modules/']
|
||||||
|
}
|
@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "esnext",
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"strict": true,
|
|
||||||
"declaration": true,
|
|
||||||
"noUnusedLocals": true,
|
|
||||||
"esModuleInterop": true
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"module": "esnext",
|
||||||
|
"target": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"strict": true,
|
||||||
|
"declaration": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"lib": ["ESNext", "DOM"],
|
||||||
|
"types": ["node", "jest"],
|
||||||
|
"paths": {
|
||||||
|
"src/*": ["src/*"],
|
||||||
|
"client/*": ["src/client/*"],
|
||||||
|
"node/*": ["src/node/*"],
|
||||||
|
"shared/*": ["src/shared/*"],
|
||||||
|
"tests/*": ["__tests__/*"],
|
||||||
|
"/@app/*": ["src/client/app/*"],
|
||||||
|
"/@theme/*": ["src/client/theme-default/*"],
|
||||||
|
"/@shared/*": ["src/client/shared/*"],
|
||||||
|
"/@types/*": ["types/*"],
|
||||||
|
"vitepress": ["src/client/app/exports.ts"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src",
|
||||||
|
"__tests__"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in new issue