-
Notifications
You must be signed in to change notification settings - Fork 1
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 #1015 from US-Trustee-Program/CAMS-442-test-coverage
CAMS-442 test coverage
- Loading branch information
Showing
12 changed files
with
288 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { azureToCamsHttpRequest, toAzureSuccess } from './functions'; | ||
import { HttpRequest, HttpResponseInit } from '@azure/functions'; | ||
import { CamsHttpRequest } from '../lib/adapters/types/http'; | ||
import { CamsHttpResponseInit } from '../lib/adapters/utils/http-response'; | ||
|
||
describe('functions test', () => { | ||
test('should return properly formatted CamsHttpRequest from malformed headers and query', async () => { | ||
const request = { | ||
method: 'GET', | ||
url: '/test', | ||
query: 'bar', | ||
params: { arg1: 'hello' }, | ||
} as unknown as HttpRequest; | ||
|
||
const expected: CamsHttpRequest = { | ||
method: 'GET', | ||
url: '/test', | ||
headers: {}, | ||
query: {}, | ||
params: { arg1: 'hello' }, | ||
body: undefined, | ||
}; | ||
|
||
const response = await azureToCamsHttpRequest(request); | ||
expect(response).toEqual(expected); | ||
}); | ||
|
||
test('should return empty Azure response init', () => { | ||
const responseInit = toAzureSuccess(); | ||
expect(responseInit).toEqual({}); | ||
}); | ||
|
||
test('should return Azure response init', () => { | ||
const camsResponseInit: CamsHttpResponseInit<{ prop1: boolean }> = { | ||
headers: { foo: 'bar' }, | ||
statusCode: 200, | ||
body: { data: { prop1: true } }, | ||
}; | ||
const expected: HttpResponseInit = { | ||
headers: { foo: 'bar' }, | ||
status: 200, | ||
jsonBody: { data: { prop1: true } }, | ||
}; | ||
const responseInit = toAzureSuccess(camsResponseInit); | ||
expect(responseInit).toEqual(expected); | ||
}); | ||
}); |
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
Oops, something went wrong.