Skip to content

Commit

Permalink
feat(string): add string test case (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wing-9527 committed Oct 28, 2022
1 parent 4bd2e2b commit 7570fb0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/string.test.ts
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest'
import { template } from './string'
import { ensurePrefix, ensureSuffix, slash, template } from './string'

it('template', () => {
expect(
Expand Down Expand Up @@ -33,3 +33,19 @@ it('template', () => {
),
).toEqual('Hi')
})

it('slash', () => {
expect(slash('\\123')).toEqual('/123')
expect(slash('\\\\')).toEqual('//')
expect(slash('\\\h\\\i')).toEqual('/h/i')
})

it('ensurePrefix', () => {
expect(ensurePrefix('abc', 'abcdef')).toEqual('abcdef')
expect(ensurePrefix('hi ', 'jack')).toEqual('hi jack')
})

it('ensureSuffix', () => {
expect(ensureSuffix('world', 'hello ')).toEqual('hello world')
expect(ensureSuffix('123', 'abc123')).toEqual('abc123')
})

0 comments on commit 7570fb0

Please sign in to comment.