Skip to content

Commit f4ed998

Browse files
committed
Refactoring
1 parent 3936cde commit f4ed998

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

test/helpers/exit.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const stopProcessLogging = function (eventName, stopLogging, processHandler) {
2727
// Start logging while `process.exit()` is being stubbed
2828
export const startExitLogging = function (opts) {
2929
stubProcessExit()
30-
return stopExitLogging.bind(undefined, startLogging(opts).stopLogging)
30+
const { stopLogging } = startLogging(opts)
31+
return stopExitLogging.bind(undefined, stopLogging)
3132
}
3233

3334
const stopExitLogging = function (stopLogging) {
@@ -37,24 +38,15 @@ const stopExitLogging = function (stopLogging) {
3738

3839
// Start logging while `setTimeout()` and `process.exit()` are being stubbed
3940
export const startClockLogging = function (opts) {
40-
const clock = stubProcessClock()
41+
const clock = fakeTimers.install({ toFake: ['setTimeout'] })
42+
stubProcessExit()
4143
const { stopLogging } = startLogging(opts)
4244
const stopLoggingA = stopClockLogging.bind(undefined, stopLogging, clock)
4345
return { clock, stopLogging: stopLoggingA }
4446
}
4547

4648
const stopClockLogging = function (stopLogging, clock) {
4749
stopLogging()
48-
unStubProcessClock(clock)
49-
}
50-
51-
// Stub `setTimeout()` and `process.exit()`
52-
const stubProcessClock = function () {
53-
stubProcessExit()
54-
return fakeTimers.install({ toFake: ['setTimeout'] })
55-
}
56-
57-
const unStubProcessClock = function (clock) {
5850
unStubProcessExit()
5951
clock.uninstall()
6052
}

0 commit comments

Comments
 (0)