Last active
July 18, 2017 12:02
-
-
Save dupski/1a6b91847dc8c155f72aafb575f35dc3 to your computer and use it in GitHub Desktop.
InversifyJS Integration Test Example
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
describe('/apps integration tests', () => { | |
let testServer: Hapi.Server; | |
let successResponse: Hapi.InjectedResponseObject; | |
let failResponse: Hapi.InjectedResponseObject; | |
beforeAll(async () => { | |
testServer = await createTestServer(); | |
container.rebind(TYPES.ILogger).toConstantValue(new MockLogger()); | |
container.rebind(TYPES.IApplicationDB).toConstantValue(new MockAppDB()); | |
successResponse = await testServer.inject({ url: '/apps?userId=12' }); | |
failResponse = await testServer.inject({ url: '/apps?userId=FAIL' }); | |
}); | |
it('renders the page title', () => { | |
expect(successResponse.payload).toContain('<h1>My Applications</h1>'); | |
}); | |
it('renders the applications from the mock App DB', () => { | |
expect(successResponse.payload).toContain('<div class="app-name">Mock App 1</div>'); | |
expect(successResponse.payload).toContain('<div class="app-name">Mock App 2</div>'); | |
}); | |
it('returns a 400 if userId is invalid', () => { | |
expect(failResponse.statusCode).toEqual(400); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment