mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
25 lines
750 B
JavaScript
25 lines
750 B
JavaScript
import uniqueSlug from './uniqueSlug'
|
|
|
|
describe('uniqueSlug', () => {
|
|
it('slugifies given string', () => {
|
|
const string = 'Hello World'
|
|
const isUnique = jest.fn().mockResolvedValue(true)
|
|
expect(uniqueSlug(string, isUnique)).resolves.toEqual('hello-world')
|
|
})
|
|
|
|
it('increments slugified string until unique', () => {
|
|
const string = 'Hello World'
|
|
const isUnique = jest
|
|
.fn()
|
|
.mockResolvedValueOnce(false)
|
|
.mockResolvedValueOnce(true)
|
|
expect(uniqueSlug(string, isUnique)).resolves.toEqual('hello-world-1')
|
|
})
|
|
|
|
it('slugify null string', () => {
|
|
const string = null
|
|
const isUnique = jest.fn().mockResolvedValue(true)
|
|
expect(uniqueSlug(string, isUnique)).resolves.toEqual('anonymous')
|
|
})
|
|
})
|