-
Notifications
You must be signed in to change notification settings - Fork 118
/
warmup.spec.js
83 lines (72 loc) · 2.08 KB
/
warmup.spec.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* eslint-env mocha */
'use strict';
const assert = require('assert');
const {
abProblem,
centuryByYearProblem,
colorsProblem,
fibonacciProblem,
matrixProblem,
numberSystemProblem,
phoneProblem,
smilesProblem,
ticTacToeProblem
} = require('./warmup');
describe('A+B problem', () => {
it('Должна вернуть `2`', () => {
assert.strictEqual(abProblem(1, 1), 2);
});
});
describe('Century by year problem', () => {
it('Должна вернуть `21`', () => {
assert.strictEqual(centuryByYearProblem(2018), 21);
});
});
describe('Colors problem', function () {
it('Должна вернуть (255, 255, 255)', function () {
assert.strictEqual(colorsProblem('#FFFFFF'), '(255, 255, 255)');
});
});
describe('Fibonacci problem', () => {
it('Для n=1 должна вернуть `1`', () => {
assert.strictEqual(fibonacciProblem(1), 1);
});
});
describe('Matrix problem', () => {
it('Должна транспонировать квадратную матрицу 3x3', () => {
assert.deepStrictEqual(
matrixProblem([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]), [
[1, 4, 7],
[2, 5, 8],
[3, 6, 9]
]);
});
});
describe('Number System Problem', () => {
it('Должна вернуть "101"', () => {
assert.strictEqual(numberSystemProblem(5, 2), '101');
});
});
describe('Phone problem', () => {
it('Для "8-800-333-51-73" должна вернуть `true`', () => {
assert.strictEqual(phoneProblem('8-800-333-51-73'), true);
});
});
describe('Smiles problem', () => {
it('Должна вернуть `1`', () => {
assert.strictEqual(smilesProblem(':-)'), 1);
});
});
describe('Tic-tac-toe problem', () => {
it('Должна вернуть "x"', () => {
assert.strictEqual(ticTacToeProblem([
['x', 'x', 'x'],
['o', 'o', 'x'],
['o', 'x', 'o']
]), 'x');
});
});