From 7ff309806585beb8053dd11f082d117d0c2112f6 Mon Sep 17 00:00:00 2001 From: Nico Jansen Date: Mon, 23 Jul 2018 22:57:54 -0700 Subject: [PATCH] test: Make use of utility `sleep` function --- packages/stryker/test/unit/SandboxPoolSpec.ts | 5 ++--- .../stryker/test/unit/transpiler/MutantTranspilerSpec.ts | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/stryker/test/unit/SandboxPoolSpec.ts b/packages/stryker/test/unit/SandboxPoolSpec.ts index 01321e84c4..6984ce3b8a 100644 --- a/packages/stryker/test/unit/SandboxPoolSpec.ts +++ b/packages/stryker/test/unit/SandboxPoolSpec.ts @@ -10,6 +10,7 @@ import { Task } from '../../src/utils/Task'; import '../helpers/globals'; import { Mock, config, file, mock, testFramework } from '../helpers/producers'; import LoggingClientContext from '../../src/logging/LoggingClientContext'; +import { sleep } from '../../src/utils/objectUtils'; const OVERHEAD_TIME_MS = 42; const LOGGING_CONTEXT: LoggingClientContext = Object.freeze({ @@ -117,8 +118,6 @@ describe('SandboxPool', () => { }); function tick() { - return new Promise(res => { - setTimeout(res, 0); - }); + return sleep(0); } diff --git a/packages/stryker/test/unit/transpiler/MutantTranspilerSpec.ts b/packages/stryker/test/unit/transpiler/MutantTranspilerSpec.ts index 58943dce1b..2d274128a6 100644 --- a/packages/stryker/test/unit/transpiler/MutantTranspilerSpec.ts +++ b/packages/stryker/test/unit/transpiler/MutantTranspilerSpec.ts @@ -6,7 +6,7 @@ import ChildProcessProxy from '../../../src/child-proxy/ChildProcessProxy'; import MutantTranspiler from '../../../src/transpiler/MutantTranspiler'; import TranspileResult from '../../../src/transpiler/TranspileResult'; import TranspilerFacade, * as transpilerFacade from '../../../src/transpiler/TranspilerFacade'; -import { errorToString } from '../../../src/utils/objectUtils'; +import { errorToString, sleep } from '../../../src/utils/objectUtils'; import '../../helpers/globals'; import { Mock, config, file, mock, testableMutant } from '../../helpers/producers'; import LoggingClientContext from '../../../src/logging/LoggingClientContext'; @@ -157,9 +157,7 @@ describe('MutantTranspiler', () => { ]; expect(actualResults).deep.eq(expectedResults); }); - const nextTick = () => new Promise(res => { - setTimeout(res, 0); - }); + const nextTick = () => sleep(0); }); });