import * as React from "react"; import PresetCalendar from "../PresetCalendar"; import { mount } from "enzyme"; import { startOfToday, endOfToday, startOfYesterday, endOfYesterday, startOfWeek, endOfWeek, startOfMonth, endOfMonth, startOfYear, endOfYear, startOfQuarter, endOfQuarter } from "date-fns"; import sinon from "sinon"; describe("PresetCalendar", () => { test("should return correct range value on apply", () => { const date = new Date(); const applySpy = sinon.spy(); const clearSpy = sinon.spy(); const changeSpy = sinon.spy(); const presetCalendar = mount( ); presetCalendar .find("button") .at(1) .simulate("click"); expect(applySpy.calledOnce).toBeTruthy(); const argument = applySpy.getCall(0).args[0]; expect(argument).toEqual([startOfToday(), endOfToday()]); }); });