-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean up importing document paths + move tests
- Loading branch information
Showing
10 changed files
with
90 additions
and
71 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
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
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
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
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,61 @@ | ||
import { expect } from 'chai' | ||
import * as request from 'supertest' | ||
import * as config from 'config' | ||
|
||
import { attachDefaultHooks } from '../../../routes/hooks' | ||
import '../../../routes/expectations' | ||
import { checkAuthorizationGuards } from '../../claim/routes/checks/authorization-check' | ||
|
||
import { Paths as ClaimDocumentsPaths } from 'claim-documents/paths' | ||
|
||
import { app } from '../../../../main/app' | ||
|
||
import * as idamServiceMock from '../../../http-mocks/idam' | ||
import * as claimStoreServiceMock from '../../../http-mocks/claim-store' | ||
|
||
const cookieName: string = config.get<string>('session.cookieName') | ||
|
||
const externalId = '400f4c57-9684-49c0-adb4-4cf46579d6dc' | ||
|
||
describe('Claim issue: receipt', () => { | ||
attachDefaultHooks(app) | ||
|
||
describe('on GET', () => { | ||
checkAuthorizationGuards(app, 'get', ClaimDocumentsPaths.receiptReceiver.evaluateUri({ externalId: externalId })) | ||
|
||
describe('for authorized user', () => { | ||
beforeEach(() => { | ||
idamServiceMock.resolveRetrieveUserFor('1', 'citizen') | ||
}) | ||
|
||
it('should return 500 and render error page when cannot retrieve claim by external id', async () => { | ||
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error') | ||
|
||
await request(app) | ||
.get(ClaimDocumentsPaths.receiptReceiver.evaluateUri({ externalId: externalId })) | ||
.set('Cookie', `${cookieName}=ABC`) | ||
.expect(res => expect(res).to.be.serverError.withText('Error')) | ||
}) | ||
|
||
it('should return 500 and render error page when cannot generate PDF', async () => { | ||
claimStoreServiceMock.resolveRetrieveClaimByExternalId() | ||
claimStoreServiceMock.rejectRetrieveDocument('HTTP error') | ||
|
||
await request(app) | ||
.get(ClaimDocumentsPaths.receiptReceiver.evaluateUri({ externalId: externalId })) | ||
.set('Cookie', `${cookieName}=ABC`) | ||
.expect(res => expect(res).to.be.serverError.withText('Error')) | ||
}) | ||
|
||
it('should return receipt when everything is fine', async () => { | ||
claimStoreServiceMock.resolveRetrieveClaimByExternalId() | ||
claimStoreServiceMock.resolveRetrieveDocument() | ||
|
||
await request(app) | ||
.get(ClaimDocumentsPaths.receiptReceiver.evaluateUri({ externalId: externalId })) | ||
.set('Cookie', `${cookieName}=ABC`) | ||
.expect(res => expect(res).to.be.successful) | ||
}) | ||
}) | ||
}) | ||
}) |
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