-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcountDown.test.js
More file actions
36 lines (29 loc) · 1.18 KB
/
countDown.test.js
File metadata and controls
36 lines (29 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// import {describe, it} from 'node:test';
import assert from 'node:assert/strict';
import {jest} from '@jest/globals';
import util from 'node:util';
import {style} from './styles.js';
import { countDownIterative } from './countDown.js';
import { countDownRecursive } from './countDown.js';
util.inspect.defaultOptions.depth = null; // show full objects
// util.inspect.defaultOptions.depth = 0; // show truncated objects
// util.inspect.defaultOptions.compact = true; // dont break objects to new lines
// util.inspect.defaultOptions.compact = false; // break objects to new lines
// suppress jests tracing console logs
import console from 'console';
const jestConsole = console;
beforeEach(() => {
global.console = console;
console.log(style.color(255,0,255),'▷',style.reset,style.color(39),expect.getState().currentTestName,style.reset,'\n'); });
afterEach(() => {
global.console = jestConsole;
console.log(style.color(99), style.hr.double, style.reset);
});
describe('countDown', () => {
it('should count down recursively and iteratively', () => {
console.log('Iterative Countdown:');
countDownIterative(3);
console.log('Recursive Countdown:');
countDownRecursive(3);
});
});