diff options
Diffstat (limited to 'spec/frontend/behaviors/date_picker_spec.js')
-rw-r--r-- | spec/frontend/behaviors/date_picker_spec.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/frontend/behaviors/date_picker_spec.js b/spec/frontend/behaviors/date_picker_spec.js new file mode 100644 index 00000000000..9f7701a0366 --- /dev/null +++ b/spec/frontend/behaviors/date_picker_spec.js @@ -0,0 +1,30 @@ +import * as Pikaday from 'pikaday'; +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'); + setFixtures(` + <div> + <input class="datepicker" value="2020-10-01" /> + </div> + <div> + <input class="datepicker" value="" /> + </div>`); + }); + + 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'], ['']]); + }); +}); |