-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from DEFRA/DSFAAP-747_timeout_for_notify_calls
Dsfaap 747 timeout for notify calls
- Loading branch information
Showing
4 changed files
with
113 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/server/common/connectors/notify/notify.integration.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { sendNotification } from './notify.js' | ||
import { config } from '~/src/config/config.js' | ||
|
||
jest.mock( | ||
'~/src/server/common/connectors/notify/notify-token-utils.js', | ||
() => ({ | ||
createToken: jest.fn().mockReturnValue('mocked-jwt-token') | ||
}) | ||
) | ||
|
||
describe('sendNotification (integration)', () => { | ||
it('should abort if the configured timeout is hit', async () => { | ||
const configGet = config.get.bind(config) | ||
const notifyConfig = { | ||
...config.get('notify'), | ||
timeout: 0 | ||
} | ||
jest.spyOn(config, 'get').mockImplementation((name) => { | ||
if (name === 'notify') { | ||
return notifyConfig | ||
} else { | ||
return configGet(name) | ||
} | ||
}) | ||
|
||
const testData = { content: 'test' } | ||
|
||
const result = sendNotification(testData) | ||
|
||
await expect(result).rejects.toThrow( | ||
'Request to GOV.uk notify timed out after 0ms' | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters