constructor(settings: ISettings) {
Model.validateSettings(settings);
this.settings = settings;
}
private static validateSettings(settings: ISettings): void {
if (settings.min >= settings.max) {
throw new Error("'max' must be greater than 'min'");
}
}
тест
let settings: ISettings;
beforeEach(() => {
settings = {
min: 0,
max: 1500,
isTwoRunners: true,
isScaleVisible: true,
isVertical: false,
isTooltipsVisible: true,
valueFrom: 1000,
valueTo: 1490,
step: 10,
};
});
describe('function validateSettings: ', () => {
test('"settings.min >= settings.max" should throw Error', () => {
settings.min = 2000;
settings.max = 1500;
expect(Model['validateSettings'](settings)).toThrow("'max' must be greater than 'min'");
});
});
ошибка