есть такая функция
private createMark(marginFromBegin: number, settings: ISettings): HTMLElement {
const mark = createElement('span', 'range-slider__scale-mark');
if (settings.isVertical) {
mark.className += ' range-slider__scale-mark_vertical';
mark.style.marginTop = `${marginFromBegin}px`;
} else {
mark.style.marginLeft = `${marginFromBegin}px`;
}
return mark;
}
пишу к ней тест
import { ISettings } from '../RangeSlider/types';
import Scale from './Scale';
let settings: ISettings;
beforeEach(() => {
settings = {
min: 0,
max: 1500,
isTwoRunners: true,
isScaleVisible: true,
isVertical: false,
isTooltipsVisible: true,
valueFrom: 1000,
valueTo: 1490,
step: 10,
};
});
function getPrivateMethod(methodName: string, marginFromBegin: number, settings: ISettings) {
const scaleProto = Scale.prototype as any;
const instance = Object.create(scaleProto);
return () => scaleProto.constructor[methodName].call(instance, marginFromBegin, settings);
}
describe('private createMark method', () => {
test('should return html element', () => {
settings.isVertical = true;
const result = getPrivateMethod('createMark', 100, settings);
console.log(result);
expect(result).not.toBeNull();
});
});
Ожидаю что в result будет html элемент mark который возвращает функция createMark,
но console.log вместо этого выводит [Function]