Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('has a button which steps back a month', async () => {
const {waitForDom} = clientRenderer.render(
);
expect(bodySelect('YEAR')).to.have.text('2017');
expect(bodySelect('MONTH_NAME')).to.have.text('January');
simulate.mouseDown(bodySelect('PREV_MONTH_BUTTON'));
await waitForDom(() => {
expect(bodySelect('YEAR')).to.have.text('2016');
expect(bodySelect('MONTH_NAME')).to.have.text('December');
});
});
it('should show and hide the dropdown when the input is clicked', async () => {
const {select, waitForDom} = clientRenderer.render();
const datePickerInput = select(datePickerInputId);
await waitForDom(() => expect(bodySelect(datePickerDropdownId)).to.be.absent());
simulate.mouseDown(datePickerInput);
await waitForDom(() => expect(bodySelect(datePickerDropdownId)).to.be.present());
simulate.mouseDown(datePickerInput);
await waitForDom(() => expect(bodySelect(datePickerDropdownId)).to.be.absent());
});
await waitFor(() => {
const element = select('SLIDER');
const handle = select('SLIDER-HANDLE');
const progress = select('SLIDER-PROGRESS');
simulate.mouseDown(element, {
currentTarget: element!,
clientX: eventMock.clientX,
clientY: eventMock.clientY
});
expect(handle!.style[positionProp as any]).to.equal('80%');
expect(progress!.style[sizeProp as any]).to.equal('80%');
});
});
public mouseDown(element: Element): void {
simulate.mouseDown(element, {button: 0});
}
await waitForDom(() => {
simulate.mouseDown(select('STEPPER'), dragStartPoint);
windowStub.simulate('mousemove', {
clientX: dragStartPoint.clientX,
clientY: dragStartPoint.clientY - dragStep,
shiftKey: true
});
expect(onUp).to.have.been.calledOnce;
expect(onUp).to.have.been.calledWithMatch({shiftKey: true});
expect(onDown).not.to.have.been.called;
});
});
await waitForDom(() => {
simulate.mouseDown(select('STEPPER'), {clientX: 100, clientY: 100});
windowStub.simulate('mousemove', {
clientX: dragStartPoint.clientX,
clientY: dragStartPoint.clientY - dragStep
});
windowStub.simulate('mousemove', {
clientX: dragStartPoint.clientX,
clientY: dragStartPoint.clientY + dragStep
});
windowStub.simulate('mouseup');
windowStub.simulate('mousemove', {
clientX: dragStartPoint.clientX,
clientY: dragStartPoint.clientY - dragStep
});
windowStub.simulate('mousemove', {
clientX: dragStartPoint.clientX,
clientY: dragStartPoint.clientY + dragStep
public clickOnDay(day: number): void {
simulate.mouseDown(this.getDay(day));
}
public mouseDown(event: SliderEventCoordinates) {
const element = this.slider;
simulate.mouseDown(element, {
preventDefault: noop,
currentTarget: element!,
clientX: event.clientX,
clientY: event.clientY
});
}
public mouseMove(event: SliderEventCoordinates, environment: WindowStub) {
public clickOnNextMonth(): void {
simulate.mouseDown(this.nextMonthLabel);
}
public clickOnPrevMonth(): void {
simulate.mouseDown(this.prevMonthLabel);
}