-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.test.js
33 lines (25 loc) · 920 Bytes
/
utils.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
const { reverse, rotate, roundOff } = require('./utils');
test('reverse([1, 2, 3]) = [3, 2, 1]', () => {
expect(reverse([1, 2, 3])).toStrictEqual([3, 2, 1]);
});
test('rotate([1, 2, 3], 0) = [1, 2, 3]', () => {
expect(rotate([1, 2, 3], 0)).toStrictEqual([1, 2, 3]);
});
test('rotate([1, 2, 3]) = rotate([1, 2, 3], 1) = [2, 3, 1]', () => {
expect(rotate([1, 2, 3], 1)).toStrictEqual([2, 3, 1]);
});
test('rotate([1, 2, 3], 2) = [3, 1, 2]', () => {
expect(rotate([1, 2, 3], 2)).toStrictEqual([3, 1, 2]);
});
test('rotate([1, 2, 3], 3) = [1, 2, 3]', () => {
expect(rotate([1, 2, 3], 3)).toStrictEqual([1, 2, 3]);
});
test('rotate([1, 2, 3], 4) = [2, 3, 1]', () => {
expect(rotate([1, 2, 3], 4)).toStrictEqual([2, 3, 1]);
});
test('roundOff(123.45, 1) = 123.5', () => {
expect(roundOff(123.45, 1)).toBe(123.5);
});
test('roundOff(0.254, 2) = 0.25', () => {
expect(roundOff(0.254, 2)).toBe(0.25);
});