chore: Clean up unused files, imports, and work on getting end-to-end tests and unit tests running (#2272)
This commit is contained in:
1 parent
414ebc6850
commit
0db81b30f3
374 files changed
+14138
-21288
No files matched your search
@@ -21,12 +21,12 @@ describe('Queue', () => {
|
||||
const mockedTimeout = jest.fn(timeout);
|
||||
const timer = queue.bind(mockedTimeout);
|
||||
const start = Date.now();
|
||||
timer(120).then(now => {
|
||||
timer(1200).then(now => {
|
||||
const elapsed = now - start;
|
||||
expect(elapsed >= 120 && elapsed < 240).toBe(true);
|
||||
expect(elapsed >= 1200 && elapsed < 2400).toBe(true);
|
||||
});
|
||||
const end = await timer(120);
|
||||
expect(end - start > 240).toBe(true);
|
||||
const end = await timer(1200);
|
||||
expect(end - start > 2400).toBe(true);
|
||||
expect(mockedTimeout).toBeCalledTimes(2);
|
||||
});
|
||||
it('should prevent task execution when queue limit is reached', async () => {
|
||||
@@ -34,15 +34,15 @@ describe('Queue', () => {
|
||||
const mockedTimeout = jest.fn(timeout);
|
||||
const timer = queue.bind(mockedTimeout);
|
||||
const start = Date.now();
|
||||
const promise = timer(120).then(time => time - start);
|
||||
const promise = timer(1200).then(time => time - start);
|
||||
try {
|
||||
await timer(120);
|
||||
await timer(1200);
|
||||
} catch (e) {
|
||||
expect(Date.now() - start < 120).toBe(true);
|
||||
expect(Date.now() - start < 1200).toBe(true);
|
||||
expect(e.message).toBe('Queue limit reached');
|
||||
}
|
||||
const elapsed = await promise;
|
||||
expect(elapsed >= 120 && elapsed < 240).toBe(true);
|
||||
expect(elapsed >= 1200 && elapsed < 2400).toBe(true);
|
||||
expect(mockedTimeout).toBeCalledTimes(1);
|
||||
});
|
||||
it('should safely bind tasks to the queue', async () => {
|
||||
@@ -51,16 +51,16 @@ describe('Queue', () => {
|
||||
const mockedTimeout = jest.fn(timeout);
|
||||
const timer = queue.bindSafe(mockedTimeout, mockedErrorHandler);
|
||||
const start = Date.now();
|
||||
const promise = timer(120).then(time => time - start);
|
||||
await timer(120);
|
||||
expect(Date.now() - start < 120).toBe(true);
|
||||
const promise = timer(1200).then(time => time - start);
|
||||
await timer(1200);
|
||||
expect(Date.now() - start < 1200).toBe(true);
|
||||
expect(mockedErrorHandler).toBeCalledTimes(1);
|
||||
expect(mockedErrorHandler).nthCalledWith(
|
||||
1,
|
||||
expect.objectContaining({ message: 'Queue limit reached' })
|
||||
);
|
||||
const elapsed = await promise;
|
||||
expect(elapsed >= 120 && elapsed < 240).toBe(true);
|
||||
expect(elapsed >= 1200 && elapsed < 2400).toBe(true);
|
||||
expect(mockedTimeout).toBeCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,3 @@
|
||||
import OHIFError from '../classes/OHIFError.js';
|
||||
|
||||
let stackMap = {};
|
||||
let configuration = {};
|
||||
const stackUpdatedCallbacks = [];
|
||||
@@ -110,7 +108,7 @@ const StackManager = {
|
||||
*/
|
||||
addStackUpdatedCallback(callback) {
|
||||
if (typeof callback !== 'function') {
|
||||
throw new OHIFError('callback must be provided as a function');
|
||||
throw new Error('callback must be provided as a function');
|
||||
}
|
||||
stackUpdatedCallbacks.push(callback);
|
||||
},
|
||||
|
||||
@@ -190,4 +190,6 @@ function toSublist(value) {
|
||||
* Exports
|
||||
*/
|
||||
|
||||
const hierarchicalListUtils = { addToList, getItem, forEach, print };
|
||||
export { addToList, getItem, forEach, print };
|
||||
export default hierarchicalListUtils;
|
||||
@@ -1,28 +1,41 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* This extension allows you to record a sequence using Mousetrap.
|
||||
* {@link https://craig.is/killing/mice}
|
||||
*
|
||||
* @author Dan Tao <daniel.tao@gmail.com>
|
||||
*/
|
||||
export default function(Mousetrap) {
|
||||
module.exports = function (Mousetrap, options) {
|
||||
/**
|
||||
* the default configurations, we merge with user options
|
||||
*
|
||||
* @type {Array}
|
||||
*/
|
||||
var _config = Object.assign({
|
||||
timeout: 1000
|
||||
}, options);
|
||||
|
||||
/**
|
||||
* the sequence currently being recorded
|
||||
*
|
||||
* @type {Array}
|
||||
*/
|
||||
var _recordedSequence = [],
|
||||
|
||||
/**
|
||||
* a callback to invoke after recording a sequence
|
||||
*
|
||||
* @type {Function|null}
|
||||
*/
|
||||
_recordedSequenceCallback = null,
|
||||
|
||||
/**
|
||||
* a list of all of the keys currently held down
|
||||
*
|
||||
* @type {Array}
|
||||
*/
|
||||
_currentRecordedKeys = [],
|
||||
|
||||
/**
|
||||
* temporary state where we remember if we've already captured a
|
||||
* character key in the current combo
|
||||
@@ -30,19 +43,28 @@ export default function(Mousetrap) {
|
||||
* @type {boolean}
|
||||
*/
|
||||
_recordedCharacterKey = false,
|
||||
|
||||
/**
|
||||
* a handle for the timer of the current recording
|
||||
*
|
||||
* @type {null|number}
|
||||
*/
|
||||
_recordTimer = null,
|
||||
|
||||
/**
|
||||
* the original handleKey method to override when Mousetrap.record() is
|
||||
* called
|
||||
*
|
||||
* @type {Function}
|
||||
*/
|
||||
_origHandleKey = Mousetrap.prototype.handleKey;
|
||||
_origHandleKey = Mousetrap.prototype.handleKey,
|
||||
|
||||
/**
|
||||
* the timeout that timer will wait for a key
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
_recordTimeout = _config.timeout;
|
||||
|
||||
/**
|
||||
* handles a character key event
|
||||
@@ -61,19 +83,19 @@ export default function(Mousetrap) {
|
||||
}
|
||||
|
||||
// remember this character if we're currently recording a sequence
|
||||
if (e.type == 'keydown') {
|
||||
if (e.type === 'keydown') {
|
||||
if (character.length === 1 && _recordedCharacterKey) {
|
||||
_recordCurrentCombo();
|
||||
}
|
||||
|
||||
for (let i = 0; i < modifiers.length; ++i) {
|
||||
for (var i = 0; i < modifiers.length; ++i) {
|
||||
_recordKey(modifiers[i]);
|
||||
}
|
||||
_recordKey(character);
|
||||
|
||||
// once a key is released, all keys that were held down at the time
|
||||
// count as a keypress
|
||||
} else if (e.type == 'keyup' && _currentRecordedKeys.length > 0) {
|
||||
} else if (e.type === 'keyup' && _currentRecordedKeys.length > 0) {
|
||||
_recordCurrentCombo();
|
||||
}
|
||||
}
|
||||
@@ -85,8 +107,10 @@ export default function(Mousetrap) {
|
||||
* @returns void
|
||||
*/
|
||||
function _recordKey(key) {
|
||||
var i;
|
||||
|
||||
// one-off implementation of Array.indexOf, since IE6-9 don't support it
|
||||
for (let i = 0; i < _currentRecordedKeys.length; ++i) {
|
||||
for (i = 0; i < _currentRecordedKeys.length; ++i) {
|
||||
if (_currentRecordedKeys[i] === key) {
|
||||
return;
|
||||
}
|
||||
@@ -109,7 +133,7 @@ export default function(Mousetrap) {
|
||||
_recordedSequence.push(_currentRecordedKeys);
|
||||
_currentRecordedKeys = [];
|
||||
_recordedCharacterKey = false;
|
||||
_finishRecording();
|
||||
_restartRecordTimer();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +146,9 @@ export default function(Mousetrap) {
|
||||
* @returns void
|
||||
*/
|
||||
function _normalizeSequence(sequence) {
|
||||
for (let i = 0; i < sequence.length; ++i) {
|
||||
var i;
|
||||
|
||||
for (i = 0; i < sequence.length; ++i) {
|
||||
sequence[i].sort(function(x, y) {
|
||||
// modifier keys always come first, in alphabetical order
|
||||
if (x.length > 1 && y.length === 1) {
|
||||
@@ -168,7 +194,7 @@ export default function(Mousetrap) {
|
||||
*/
|
||||
function _restartRecordTimer() {
|
||||
clearTimeout(_recordTimer);
|
||||
_recordTimer = setTimeout(_finishRecording, 1000);
|
||||
_recordTimer = setTimeout(_finishRecording, _recordTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,41 +204,27 @@ export default function(Mousetrap) {
|
||||
* @param {Function} callback
|
||||
* @returns void
|
||||
*/
|
||||
Mousetrap.prototype.record = function(callback) {
|
||||
Mousetrap.prototype.record = function(callback, timeout) {
|
||||
var self = this;
|
||||
self.recording = true;
|
||||
|
||||
// if the user doesn't want to change the timeout
|
||||
// we still need to guarantee that it gets the default timeout
|
||||
_recordTimeout = timeout || _config.timeout;
|
||||
|
||||
_recordedSequenceCallback = function() {
|
||||
self.recording = false;
|
||||
callback.apply(self, arguments);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* stop recording
|
||||
*
|
||||
* @param {Function} callback
|
||||
* @returns void
|
||||
*/
|
||||
Mousetrap.prototype.stopRecord = function() {
|
||||
var self = this;
|
||||
self.recording = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* start recording
|
||||
*
|
||||
* @param {Function} callback
|
||||
* @returns void
|
||||
*/
|
||||
Mousetrap.prototype.startRecording = function() {
|
||||
var self = this;
|
||||
self.recording = true;
|
||||
};
|
||||
|
||||
Mousetrap.prototype.handleKey = function() {
|
||||
var self = this;
|
||||
_handleKey.apply(self, arguments);
|
||||
};
|
||||
|
||||
Mousetrap.init();
|
||||
}
|
||||
|
||||
return Mousetrap;
|
||||
|
||||
};
|
||||
@@ -1,7 +1,6 @@
|
||||
import ObjectPath from './objectPath';
|
||||
import StackManager from './StackManager.js';
|
||||
import absoluteUrl from './absoluteUrl';
|
||||
import addServers from './addServers';
|
||||
import guid from './guid';
|
||||
import sortBy from './sortBy.js';
|
||||
import sortBySeriesDate from './sortBySeriesDate.js';
|
||||
@@ -9,7 +8,7 @@ import writeScript from './writeScript.js';
|
||||
import DicomLoaderService from './dicomLoaderService.js';
|
||||
import b64toBlob from './b64toBlob.js';
|
||||
//import loadAndCacheDerivedDisplaySets from './loadAndCacheDerivedDisplaySets.js';
|
||||
import * as urlUtil from './urlUtil';
|
||||
import urlUtil from './urlUtil';
|
||||
import makeDeferred from './makeDeferred';
|
||||
import makeCancelable from './makeCancelable';
|
||||
import hotkeys from './hotkeys';
|
||||
@@ -18,19 +17,17 @@ import isDicomUid from './isDicomUid';
|
||||
import formatDate from './formatDate';
|
||||
import formatPN from './formatPN';
|
||||
import resolveObjectPath from './resolveObjectPath';
|
||||
import * as hierarchicalListUtils from './hierarchicalListUtils';
|
||||
import * as progressTrackingUtils from './progressTrackingUtils';
|
||||
import hierarchicalListUtils from './hierarchicalListUtils';
|
||||
import progressTrackingUtils from './progressTrackingUtils';
|
||||
import isLowPriorityModality from './isLowPriorityModality';
|
||||
|
||||
// Commented out unused functionality.
|
||||
// Now that we have the DicomMetadataStore, we no longer need the studyMetadataManager
|
||||
// Need to implement new mechanism for dervived displaySets using the displaySetManager.
|
||||
|
||||
const utils = {
|
||||
guid,
|
||||
ObjectPath,
|
||||
absoluteUrl,
|
||||
addServers,
|
||||
sortBy,
|
||||
sortBySeriesDate,
|
||||
writeScript,
|
||||
@@ -38,7 +35,6 @@ const utils = {
|
||||
formatPN,
|
||||
b64toBlob,
|
||||
StackManager,
|
||||
//studyMetadataManager,
|
||||
DicomLoaderService,
|
||||
urlUtil,
|
||||
//loadAndCacheDerivedDisplaySets,
|
||||
@@ -57,7 +53,6 @@ export {
|
||||
guid,
|
||||
ObjectPath,
|
||||
absoluteUrl,
|
||||
addServers,
|
||||
sortBy,
|
||||
formatDate,
|
||||
writeScript,
|
||||
|
||||
@@ -6,13 +6,15 @@ describe('Top level exports', () => {
|
||||
'guid',
|
||||
'ObjectPath',
|
||||
'absoluteUrl',
|
||||
'addServers',
|
||||
'sortBy',
|
||||
'sortBySeriesDate',
|
||||
'isLowPriorityModality',
|
||||
'writeScript',
|
||||
'b64toBlob',
|
||||
'StackManager',
|
||||
'studyMetadataManager',
|
||||
'loadAndCacheDerivedDisplaySets',
|
||||
'formatDate',
|
||||
'formatPN',
|
||||
//'loadAndCacheDerivedDisplaySets',
|
||||
'DicomLoaderService',
|
||||
'urlUtil',
|
||||
'makeDeferred',
|
||||
|
||||
@@ -3,7 +3,6 @@ import log from '../../log';
|
||||
export default function getPixelSpacingInformation(instance) {
|
||||
// See http://gdcm.sourceforge.net/wiki/index.php/Imager_Pixel_Spacing
|
||||
|
||||
// TODO: Add Ultrasound region spacing
|
||||
// TODO: Add manual calibration
|
||||
|
||||
// TODO: Use ENUMS from dcmjs
|
||||
|
||||
@@ -318,7 +318,7 @@ function notify(list, data) {
|
||||
* Exports
|
||||
*/
|
||||
|
||||
export {
|
||||
const progressTrackingUtils = {
|
||||
createList,
|
||||
isList,
|
||||
createTask,
|
||||
@@ -334,3 +334,5 @@ export {
|
||||
addObserver,
|
||||
removeObserver,
|
||||
};
|
||||
|
||||
export default progressTrackingUtils;
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as utils from './progressTrackingUtils';
|
||||
import utils from './progressTrackingUtils';
|
||||
|
||||
describe('progressTrackingUtils', () => {
|
||||
describe('Creation of lists of tasks to be tracked', () => {
|
||||
|
||||
@@ -70,4 +70,6 @@ const paramString = {
|
||||
replaceParam,
|
||||
};
|
||||
|
||||
export { parse, queryString, paramString };
|
||||
const urlUtil = { parse, queryString, paramString };
|
||||
|
||||
export default urlUtil;
|
||||
Reference in new issue
Block a user