From 7570fb0dddf22d54504370c552c4b3a52389cfe6 Mon Sep 17 00:00:00 2001 From: Ian Ting <49954218+Wing-9527@users.noreply.github.com> Date: Fri, 28 Oct 2022 10:28:40 +0800 Subject: [PATCH] feat(string): add string test case (#19) --- src/string.test.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/string.test.ts b/src/string.test.ts index 8070cf3..6182f02 100644 --- a/src/string.test.ts +++ b/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( @@ -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') +})