feat: Added support for i18n (#2439)
* Added translation for various react components in OHIF-v3 * Added a test language for debugging- test-LNG * Added copy for test language to not get overwritten
This commit is contained in:
1 parent
fdb6ca41d6
commit
1bf651e763
42 files changed
+365
-63
No files matched your search
@@ -15,18 +15,20 @@ function timeout(delay) {
|
||||
* Tests
|
||||
*/
|
||||
|
||||
const threshold = 2400
|
||||
|
||||
describe('Queue', () => {
|
||||
it('should bind functions to the queue', async () => {
|
||||
const queue = new Queue(2);
|
||||
const mockedTimeout = jest.fn(timeout);
|
||||
const timer = queue.bind(mockedTimeout);
|
||||
const start = Date.now();
|
||||
timer(1200).then(now => {
|
||||
timer(threshold).then(now => {
|
||||
const elapsed = now - start;
|
||||
expect(elapsed >= 1200 && elapsed < 2400).toBe(true);
|
||||
expect(elapsed >= threshold && elapsed < 2 * threshold).toBe(true);
|
||||
});
|
||||
const end = await timer(1200);
|
||||
expect(end - start > 2400).toBe(true);
|
||||
const end = await timer(threshold);
|
||||
expect(end - start > 2 * threshold).toBe(true);
|
||||
expect(mockedTimeout).toBeCalledTimes(2);
|
||||
});
|
||||
it('should prevent task execution when queue limit is reached', async () => {
|
||||
@@ -34,15 +36,15 @@ describe('Queue', () => {
|
||||
const mockedTimeout = jest.fn(timeout);
|
||||
const timer = queue.bind(mockedTimeout);
|
||||
const start = Date.now();
|
||||
const promise = timer(1200).then(time => time - start);
|
||||
const promise = timer(threshold).then(time => time - start);
|
||||
try {
|
||||
await timer(1200);
|
||||
await timer(threshold);
|
||||
} catch (e) {
|
||||
expect(Date.now() - start < 1200).toBe(true);
|
||||
expect(Date.now() - start < threshold).toBe(true);
|
||||
expect(e.message).toBe('Queue limit reached');
|
||||
}
|
||||
const elapsed = await promise;
|
||||
expect(elapsed >= 1200 && elapsed < 2400).toBe(true);
|
||||
expect(elapsed >= threshold && elapsed < 2 * threshold).toBe(true);
|
||||
expect(mockedTimeout).toBeCalledTimes(1);
|
||||
});
|
||||
it('should safely bind tasks to the queue', async () => {
|
||||
@@ -51,16 +53,16 @@ describe('Queue', () => {
|
||||
const mockedTimeout = jest.fn(timeout);
|
||||
const timer = queue.bindSafe(mockedTimeout, mockedErrorHandler);
|
||||
const start = Date.now();
|
||||
const promise = timer(1200).then(time => time - start);
|
||||
await timer(1200);
|
||||
expect(Date.now() - start < 1200).toBe(true);
|
||||
const promise = timer(threshold).then(time => time - start);
|
||||
await timer(threshold);
|
||||
expect(Date.now() - start < threshold).toBe(true);
|
||||
expect(mockedErrorHandler).toBeCalledTimes(1);
|
||||
expect(mockedErrorHandler).nthCalledWith(
|
||||
1,
|
||||
expect.objectContaining({ message: 'Queue limit reached' })
|
||||
);
|
||||
const elapsed = await promise;
|
||||
expect(elapsed >= 1200 && elapsed < 2400).toBe(true);
|
||||
expect(elapsed >= threshold && elapsed < 2 * threshold).toBe(true);
|
||||
expect(mockedTimeout).toBeCalledTimes(1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user