strings.test.ts 816 B

123456789101112131415161718192021222324252627282930
  1. import * as vueShared from '@vue/shared'
  2. import { describe, expect, it } from 'vitest'
  3. import {
  4. camelize,
  5. capitalize,
  6. escapeStringRegexp,
  7. hyphenate,
  8. kebabCase,
  9. } from '..'
  10. describe('strings', () => {
  11. it('escapeStringRegexp should work', () => {
  12. expect(escapeStringRegexp('foo')).toMatchInlineSnapshot('"foo"')
  13. expect(escapeStringRegexp('**\\//aa^~#$')).toMatchInlineSnapshot(
  14. '"\\\\*\\\\*\\\\\\\\//aa\\\\^~#\\\\$"'
  15. )
  16. })
  17. it('capitalize', () => {
  18. ;['capitalize', 'camelize', 'hyphenate'].forEach((item) => {
  19. expect(capitalize(item)).toBe(vueShared.capitalize(item))
  20. })
  21. })
  22. it('re-export from @vue/shared', () => {
  23. expect(camelize).toBe(vueShared.camelize)
  24. expect(hyphenate).toBe(vueShared.hyphenate)
  25. expect(kebabCase).toBe(vueShared.hyphenate)
  26. })
  27. })