mirror of https://github.com/nextcloud/calendar
81 lines
4.3 KiB
JavaScript
81 lines
4.3 KiB
JavaScript
/**
|
|
* @copyright Copyright (c) 2020 Georg Ehrke
|
|
*
|
|
* @author Georg Ehrke <oc.list@georgehrke.com>
|
|
*
|
|
* @license GNU AGPL version 3 or any later version
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
import { getWeekendDaysForLocale } from '../../../../../src/fullcalendar/localization/localeWeekendProvider.js'
|
|
import { getLocale } from '@nextcloud/l10n'
|
|
import dayCellClassNames from '../../../../../src/fullcalendar/rendering/dayCellClassNames.js'
|
|
jest.mock('../../../../../src/fullcalendar/localization/localeWeekendProvider.js')
|
|
jest.mock('@nextcloud/l10n')
|
|
|
|
describe('fullcalendar/dayCellClassNames test suite', () => {
|
|
|
|
beforeEach(() => {
|
|
getWeekendDaysForLocale.mockClear()
|
|
getLocale.mockClear()
|
|
})
|
|
|
|
it('should provide the correct weekend days for the us', () => {
|
|
getLocale.mockReturnValue('en_US')
|
|
getWeekendDaysForLocale.mockReturnValue([0, 6])
|
|
|
|
expect(dayCellClassNames({ date: new Date('2020-08-24T12:00:00')})).toEqual(['nc-calendar-fc-day-of-workweek'])
|
|
expect(dayCellClassNames({ date: new Date('2020-08-25T12:00:00')})).toEqual(['nc-calendar-fc-day-of-workweek'])
|
|
expect(dayCellClassNames({ date: new Date('2020-08-26T12:00:00')})).toEqual(['nc-calendar-fc-day-of-workweek'])
|
|
expect(dayCellClassNames({ date: new Date('2020-08-27T12:00:00')})).toEqual(['nc-calendar-fc-day-of-workweek'])
|
|
expect(dayCellClassNames({ date: new Date('2020-08-28T12:00:00')})).toEqual(['nc-calendar-fc-day-of-workweek'])
|
|
expect(dayCellClassNames({ date: new Date('2020-08-29T12:00:00')})).toEqual(['nc-calendar-fc-day-of-weekend'])
|
|
expect(dayCellClassNames({ date: new Date('2020-08-30T12:00:00')})).toEqual(['nc-calendar-fc-day-of-weekend'])
|
|
|
|
expect(getLocale).toHaveBeenCalledTimes(7)
|
|
expect(getWeekendDaysForLocale).toHaveBeenCalledTimes(7)
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(1, 'en_US')
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(2, 'en_US')
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(3, 'en_US')
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(4, 'en_US')
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(5, 'en_US')
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(6, 'en_US')
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(7, 'en_US')
|
|
})
|
|
|
|
it('should provide the correct weekend days for hebrew locale', () => {
|
|
getLocale.mockReturnValue('he')
|
|
getWeekendDaysForLocale.mockReturnValue([5, 6])
|
|
|
|
expect(dayCellClassNames({ date: new Date('2020-08-24T12:00:00')})).toEqual(['nc-calendar-fc-day-of-workweek'])
|
|
expect(dayCellClassNames({ date: new Date('2020-08-25T12:00:00')})).toEqual(['nc-calendar-fc-day-of-workweek'])
|
|
expect(dayCellClassNames({ date: new Date('2020-08-26T12:00:00')})).toEqual(['nc-calendar-fc-day-of-workweek'])
|
|
expect(dayCellClassNames({ date: new Date('2020-08-27T12:00:00')})).toEqual(['nc-calendar-fc-day-of-workweek'])
|
|
expect(dayCellClassNames({ date: new Date('2020-08-28T12:00:00')})).toEqual(['nc-calendar-fc-day-of-weekend'])
|
|
expect(dayCellClassNames({ date: new Date('2020-08-29T12:00:00')})).toEqual(['nc-calendar-fc-day-of-weekend'])
|
|
expect(dayCellClassNames({ date: new Date('2020-08-30T12:00:00')})).toEqual(['nc-calendar-fc-day-of-workweek'])
|
|
|
|
expect(getLocale).toHaveBeenCalledTimes(7)
|
|
expect(getWeekendDaysForLocale).toHaveBeenCalledTimes(7)
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(1, 'he')
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(2, 'he')
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(3, 'he')
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(4, 'he')
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(5, 'he')
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(6, 'he')
|
|
expect(getWeekendDaysForLocale).toHaveBeenNthCalledWith(7, 'he')
|
|
})
|
|
})
|