mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Fix slugify unit test with async mock functions
This commit is contained in:
parent
ba26c0e188
commit
a61362b269
@ -3,16 +3,16 @@ import uniqueSlug from './uniqueSlug'
|
||||
describe('uniqueSlug', () => {
|
||||
it('slugifies given string', () => {
|
||||
const string = 'Hello World'
|
||||
const isUnique = () => true
|
||||
expect(uniqueSlug(string, isUnique)).toEqual('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()
|
||||
isUnique
|
||||
.mockReturnValueOnce(false)
|
||||
.mockReturnValueOnce(true)
|
||||
expect(uniqueSlug(string, isUnique)).toEqual('hello-world-1')
|
||||
.mockResolvedValueOnce(false)
|
||||
.mockResolvedValueOnce(true)
|
||||
expect(uniqueSlug(string, isUnique)).resolves.toEqual('hello-world-1')
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user