Files
util-utils/tests/randomString.test.ts
2023-11-19 15:14:09 +01:00

14 lines
512 B
TypeScript

import { randomString } from '../src/index'
import { describe, it, expect } from 'vitest'
describe('randomString', () => {
it('should return a random string with the length of 10', () => {
const result = randomString(10)
expect(result).toHaveLength(10)
})
it('should return a random string with the length of 20 and a custom charset', () => {
const result = randomString(20, 'abc')
expect(result).toHaveLength(20)
expect(result).toMatch(/[abc]{20}/)
})
})