Skip to content

Commit

Permalink
test: add test for client utils
Browse files Browse the repository at this point in the history
close #617
  • Loading branch information
kiaking committed Jun 14, 2022
1 parent 6eda63e commit 0b6f25b
Show file tree
Hide file tree
Showing 5 changed files with 308 additions and 14 deletions.
13 changes: 13 additions & 0 deletions __tests__/client/theme-default/support/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { describe, test, expect } from 'vitest'
import * as Utils from 'client/theme-default/support/utils'

describe('client/theme-default/utils', () => {
describe('ensureStartingSlash', () => {
test('it adds 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')
})
})
})
1 change: 1 addition & 0 deletions __tests__/shims.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default '{}'
4 changes: 3 additions & 1 deletion __tests__/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ const dir = dirname(fileURLToPath(import.meta.url))
export default defineConfig({
resolve: {
alias: {
'@siteData': resolve(dir, './shims.ts'),
client: resolve(dir, '../src/client'),
node: resolve(dir, '../src/node'),
client: resolve(dir, '../src/client')
vitepress: resolve(dir, '../src/client')
}
},
test: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"sirv": "^1.0.12",
"supports-color": "^9.2.2",
"typescript": "^4.7.2",
"vitest": "^0.10.4"
"vitest": "^0.14.2"
},
"pnpm": {
"peerDependencyRules": {
Expand Down
Loading

0 comments on commit 0b6f25b

Please sign in to comment.