Skip to content

Commit

Permalink
test(callback): Correcting not calling callback
Browse files Browse the repository at this point in the history
  • Loading branch information
Luc Merceron committed Sep 18, 2017
1 parent d123a0d commit cbd97de
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/referenceFetcher.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,13 @@ describe('FetchRefs util', () => {
fetch: () => new Promise((resolve, reject) => reject('Error in Promise')),
}],
})
const configWithUnknownRef = debounceCallback => ({
const configWithUnknownRef = () => ({
entity: 'parcels',
fetch: parcelsPromise,
refs: [{
entity: 'doesNotExist',
optional: true,
fetch: noId => {
debounceCallback()
return subObjectPromise(noId)
},
fetch: noId => subObjectPromise(noId),
}],
})

Expand Down Expand Up @@ -314,9 +311,11 @@ describe('FetchRefs util', () => {
expect(global.console.error).toHaveBeenCalledTimes(0) // Should not be called 3 times (parcels.length)
done()
}
const debounceCallback = debounce(callback, 10)
const debounceCallback = debounce(callback, 100)
// Mocking console error function
global.console.error = jest.fn().mockImplementation(debounceCallback)
fetchRefs(configWithUnknownRef(debounceCallback))
fetchRefs(configWithUnknownRef())
// Calling debounceCallback as to start the debouncing
debounceCallback()
})
})

0 comments on commit cbd97de

Please sign in to comment.