element-plus/packages/utils/__tests__/strings.test.ts
qiang c4d0c6f90a
refactor(components): [tabs] improve types (#9561)
Co-authored-by: 三咲智子 <sxzz@sxzz.moe>
2022-09-06 16:26:17 +00:00

31 lines
816 B
TypeScript

import * as vueShared from '@vue/shared'
import { describe, expect, it } from 'vitest'
import {
camelize,
capitalize,
escapeStringRegexp,
hyphenate,
kebabCase,
} from '..'
describe('strings', () => {
it('escapeStringRegexp should work', () => {
expect(escapeStringRegexp('foo')).toMatchInlineSnapshot('"foo"')
expect(escapeStringRegexp('**\\//aa^~#$')).toMatchInlineSnapshot(
'"\\\\*\\\\*\\\\\\\\//aa\\\\^~#\\\\$"'
)
})
it('capitalize', () => {
;['capitalize', 'camelize', 'hyphenate'].forEach((item) => {
expect(capitalize(item)).toBe(vueShared.capitalize(item))
})
})
it('re-export from @vue/shared', () => {
expect(camelize).toBe(vueShared.camelize)
expect(hyphenate).toBe(vueShared.hyphenate)
expect(kebabCase).toBe(vueShared.hyphenate)
})
})