This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add US Core $docref implementation (#78) * feat: enable $docref based on the compiled IGs (#83) * feat: add docref to capability statement (#85)
- Loading branch information
Showing
20 changed files
with
1,219 additions
and
53 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
95 changes: 95 additions & 0 deletions
95
src/operationDefinitions/OperationDefinitionRegistry.test.ts
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,95 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
import { Router } from 'express'; | ||
import ConfigHandler from '../configHandler'; | ||
import { OperationDefinitionRegistry } from './OperationDefinitionRegistry'; | ||
import { OperationDefinitionImplementation } from './types'; | ||
import ResourceHandler from '../router/handlers/resourceHandler'; | ||
|
||
const fakeRouter = (jest.fn() as unknown) as Router; | ||
const fakeOperation: OperationDefinitionImplementation = { | ||
canonicalUrl: 'https://fwoa.com/operation/fakeOperation', | ||
name: 'fakeOperation', | ||
documentation: 'The documentation for the fakeOperation', | ||
httpVerbs: ['GET'], | ||
path: '/Patient/fakeOperation', | ||
targetResourceType: 'Patient', | ||
requestInformation: { | ||
operation: 'read', | ||
resourceType: 'Patient', | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
buildRouter: (resourceHandler: ResourceHandler) => fakeRouter, | ||
}; | ||
describe('OperationDefinitionRegistry', () => { | ||
test('getAllRouters', () => { | ||
const configHandlerMock = { | ||
getResourceHandler: jest.fn().mockReturnValue({}), | ||
}; | ||
|
||
const operationDefinitionRegistry = new OperationDefinitionRegistry( | ||
(configHandlerMock as unknown) as ConfigHandler, | ||
[fakeOperation], | ||
); | ||
|
||
expect(operationDefinitionRegistry.getAllRouters()).toHaveLength(1); | ||
expect(operationDefinitionRegistry.getAllRouters()[0]).toBe(fakeRouter); | ||
}); | ||
|
||
test('getOperation', () => { | ||
const configHandlerMock = { | ||
getResourceHandler: jest.fn().mockReturnValue({}), | ||
}; | ||
|
||
const operationDefinitionRegistry = new OperationDefinitionRegistry( | ||
(configHandlerMock as unknown) as ConfigHandler, | ||
[fakeOperation], | ||
); | ||
|
||
expect(operationDefinitionRegistry.getOperation('PATCH', '/Patient/fakeOperation')).toBeUndefined(); | ||
expect(operationDefinitionRegistry.getOperation('GET', '/Patient/someOtherOperation')).toBeUndefined(); | ||
|
||
expect(operationDefinitionRegistry.getOperation('GET', '/Patient/fakeOperation')).toBe(fakeOperation); | ||
}); | ||
|
||
test('getCapabilities', () => { | ||
const configHandlerMock = { | ||
getResourceHandler: jest.fn().mockReturnValue({}), | ||
}; | ||
|
||
const operationDefinitionRegistry = new OperationDefinitionRegistry( | ||
(configHandlerMock as unknown) as ConfigHandler, | ||
[fakeOperation], | ||
); | ||
|
||
expect(operationDefinitionRegistry.getCapabilities()).toMatchInlineSnapshot(` | ||
Object { | ||
"Patient": Object { | ||
"operation": Array [ | ||
Object { | ||
"definition": "https://fwoa.com/operation/fakeOperation", | ||
"documentation": "The documentation for the fakeOperation", | ||
"name": "fakeOperation", | ||
}, | ||
], | ||
}, | ||
} | ||
`); | ||
}); | ||
|
||
test('ResourceHandler not available', () => { | ||
const configHandlerMock = { | ||
getResourceHandler: jest.fn().mockReturnValue(undefined), | ||
}; | ||
|
||
expect( | ||
() => new OperationDefinitionRegistry((configHandlerMock as unknown) as ConfigHandler, [fakeOperation]), | ||
).toThrowErrorMatchingInlineSnapshot( | ||
`"Failed to initialize operation https://fwoa.com/operation/fakeOperation. Is your FhirConfig correct?"`, | ||
); | ||
}); | ||
}); |
Oops, something went wrong.