2019-08-13 15:36:46 -04:00
|
|
|
import { retrieveStudyMetadata } from './retrieveStudyMetadata.js';
|
|
|
|
|
|
|
|
|
|
const fakeDicomWebServer = {};
|
|
|
|
|
|
|
|
|
|
// Testing Promises: https://jestjs.io/docs/en/asynchronous#promises
|
|
|
|
|
describe('retrieveStudyMetadata.js', () => {
|
|
|
|
|
it('throws an exception if no server parameter is provided', () => {
|
|
|
|
|
const callWithNoServer = () => {
|
|
|
|
|
retrieveStudyMetadata(null, 'fake-study-instance-uid');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(callWithNoServer).toThrow(Error);
|
|
|
|
|
});
|
|
|
|
|
|
2020-03-09 19:03:23 +00:00
|
|
|
it('throws an exception if no StudyInstanceUID parameter is provided', () => {
|
|
|
|
|
const callWithNoStudyInstanceUID = () => {
|
2019-08-13 15:36:46 -04:00
|
|
|
retrieveStudyMetadata(fakeDicomWebServer, null);
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-09 19:03:23 +00:00
|
|
|
expect(callWithNoStudyInstanceUID).toThrow(Error);
|
2019-08-13 15:36:46 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('caches and returns the same promise for identical studyInstanceUIDs', () => {
|
|
|
|
|
const firstPromise = retrieveStudyMetadata(
|
|
|
|
|
fakeDicomWebServer,
|
|
|
|
|
'fake-study-instance-uid'
|
|
|
|
|
);
|
|
|
|
|
const secondPromise = retrieveStudyMetadata(
|
|
|
|
|
fakeDicomWebServer,
|
|
|
|
|
'fake-study-instance-uid'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(firstPromise).toBe(secondPromise);
|
|
|
|
|
});
|
|
|
|
|
});
|