gitlab-org--gitlab-foss/spec/frontend/behaviors/date_picker_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
954 B
JavaScript
Raw Normal View History

import * as Pikaday from 'pikaday';
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
import initDatePickers from '~/behaviors/date_picker';
import * as utils from '~/lib/utils/datetime_utility';
jest.mock('pikaday');
jest.mock('~/lib/utils/datetime_utility');
describe('date_picker behavior', () => {
let pikadayMock;
let parseMock;
beforeEach(() => {
pikadayMock = jest.spyOn(Pikaday, 'default');
parseMock = jest.spyOn(utils, 'parsePikadayDate');
setHTMLFixture(`
<div>
<input class="datepicker" value="2020-10-01" />
</div>
<div>
<input class="datepicker" value="" />
</div>`);
});
afterEach(() => {
resetHTMLFixture();
});
it('Instantiates Pickaday for every instance of a .datepicker class', () => {
initDatePickers();
expect(pikadayMock.mock.calls.length).toEqual(2);
expect(parseMock.mock.calls).toEqual([['2020-10-01'], ['']]);
});
});