-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample-code.test.js
More file actions
36 lines (29 loc) · 1.29 KB
/
example-code.test.js
File metadata and controls
36 lines (29 loc) · 1.29 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
35
// Простые тесты для демонстрации coverage
const { calculateSum, processData, complexFunction } = require('./example-code');
describe('calculateSum', () => {
test('должен складывать два числа', () => {
expect(calculateSum(2, 3)).toBe(5);
expect(calculateSum(-1, 1)).toBe(0);
expect(calculateSum(0, 0)).toBe(0);
});
});
describe('processData', () => {
test('должен удваивать положительные числа', () => {
expect(processData([1, 2, 3])).toEqual([2, 4, 6]);
});
test('должен игнорировать отрицательные числа', () => {
expect(processData([1, -2, 3])).toEqual([2, 6]);
});
test('должен обрабатывать пустой массив', () => {
expect(processData([])).toEqual([]);
});
});
describe('complexFunction', () => {
test('должен правильно обрабатывать положительные числа', () => {
expect(complexFunction(1, 2, 3)).toBe(6);
expect(complexFunction(1, 2, -1)).toBe(3);
});
test('должен возвращать 0 для отрицательного x', () => {
expect(complexFunction(-1, 2, 3)).toBe(0);
});
});