/
regression.tests.ts
62 lines (51 loc) · 1.44 KB
/
regression.tests.ts
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
import {runRegression, registerRegression, Regression, RegressionEnv} from './regression';
interface IBoxProps {
width: number;
height: number;
}
class Box {
constructor(public size: IBoxProps) {
}
setSize(size: IBoxProps) {
this.size = size;
}
}
interface IRBoxEnv extends RegressionEnv {
}
class RBox extends Regression<Box, IBoxProps, IRBoxEnv> {
static log: any = {};
// Фабрика для создания тестируемого объекта
factory(Class, size) {
return new Class(size);
}
// Метод обновления свойств тестируемого объекта
update(box, size) {
box.setSize(size);
}
// Получение списка регрессионых тестов
getAll() {
return {
// Название теста / describe(...)
'width & height': {
// Данные для инициализации и тест
initialData: {width: 1, height: 2},
initialTest(box, data) {
RBox.log.initialTest = {data, size: box.size};
},
// Новые данные и тест на их изменение
data: {width: 3},
test(box, data) {
RBox.log.test = {data, size: box.size};
}
}
};
}
}
describe('IBox', () => {
registerRegression('IBox', RBox);
runRegression(['IBox'], Box);
it('results', () => {
expect(RBox.log.initialTest.data).toEqual(RBox.log.initialTest.size);
expect(RBox.log.test.data.width).toEqual(RBox.log.test.size.width);
});
});