-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrainWater.test.js
35 lines (28 loc) · 1.1 KB
/
rainWater.test.js
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';
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);
});
import rainWater from './rainWater.js';
describe('rainWater', () => {
it('should calculate trapped rainwater', () => {
const input = [4, 2, 1, 3, 0, 1, 2];
const rain = rainWater(input);
expect(rain)
.toStrictEqual(6);
});
});