Skip to content

Commit

Permalink
adjust tests to new build system
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Jul 24, 2019
1 parent 1bfeb3b commit 8b26981
Show file tree
Hide file tree
Showing 20 changed files with 102 additions and 60 deletions.
3 changes: 2 additions & 1 deletion packages/__tests__/src/date-render/dayNumbers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import arLocale from '@fullcalendar/core/locales/ar'
import { getDayOfWeekHeaderElTopElText } from '../view-render/DayGridRenderUtils'

describe('dayNumbers', function() {
Expand All @@ -8,7 +9,7 @@ describe('dayNumbers', function() {
it('respects locale in month view', function() {
initCalendar({
defaultView: 'dayGridMonth',
locale: 'ar'
locale: arLocale
})
expect(getDayOfWeekHeaderElTopElText('2018-01-01')).toMatch(/1|١٤?/) // normal 1, or an Arabic 1
})
Expand Down
16 changes: 7 additions & 9 deletions packages/__tests__/src/datelib/luxon.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { Calendar } from '@fullcalendar/core'
import esLocale from '@fullcalendar/core/locales/es'
import LuxonPlugin, { toDateTime, toDuration } from '@fullcalendar/luxon'
import DayGridPlugin from '@fullcalendar/daygrid'
import { getSingleEl, getEventElTimeText } from '../event-render/EventRenderUtils'
import { testTimeZoneImpl } from './timeZoneImpl'
import * as luxon from 'luxon'

if (!luxon) {
console.log('Luxon not present. Skipping related tests.')
}

// eslint-disable-next-line
luxon &&
describe('luxon plugin', function() {

const PLUGINS = [ LuxonPlugin, DayGridPlugin ] // for `new Calendar`
pushOptions({ plugins: PLUGINS }) // for initCalendar

pushOptions({ // for initCalendar
plugins: PLUGINS
})

testTimeZoneImpl(LuxonPlugin)

Expand Down Expand Up @@ -73,7 +71,7 @@ describe('luxon plugin', function() {
let calendar = new Calendar(document.createElement('div'), {
plugins: PLUGINS,
events: [ { start: '2018-09-05T12:00:00', end: '2018-09-05T18:00:00' } ],
locale: 'es'
locale: esLocale
})
let event = calendar.getEvents()[0]
var datetime = toDateTime(event.start, calendar)
Expand Down Expand Up @@ -103,7 +101,7 @@ describe('luxon plugin', function() {
let calendar = new Calendar(document.createElement('div'), {
plugins: PLUGINS,
defaultTimedEventDuration: '05:00',
locale: 'es'
locale: esLocale
})

// hacky way to have a duration parsed
Expand Down
2 changes: 2 additions & 0 deletions packages/__tests__/src/datelib/moment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Calendar } from '@fullcalendar/core'
import MomentPlugin, { toMoment, toDuration } from '@fullcalendar/moment'
import DayGridPlugin from '@fullcalendar/daygrid'
import { getSingleEl, getEventElTimeText } from '../event-render/EventRenderUtils'
import 'moment/locale/es' // only test spanish


describe('moment plugin', function() {

Expand Down
10 changes: 9 additions & 1 deletion packages/__tests__/src/globals.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@

/// <reference path="./global-defs.d.ts" />


// NOTE: a bunch of other top-level JS files in karma.config.js

import './hacks'
import './lib/simulate'
import './lib/date-matchers'

import { Calendar } from '@fullcalendar/core'
import InteractionPlugin from '@fullcalendar/interaction'
import DayGridPlugin from '@fullcalendar/daygrid'
import TimeGridPlugin from '@fullcalendar/timegrid'
import ListPlugin from '@fullcalendar/list'

import { __assign } from 'tslib'
import { parseLocalDate, parseUtcDate } from './lib/date-parsing'

Expand Down Expand Up @@ -238,7 +246,7 @@ __assign(window, {
// Defaults that apply to all tests
// ---------------------------------------------------------------------------------------------------------------------

const DEFAULT_PLUGINS = [
export const DEFAULT_PLUGINS = [
InteractionPlugin,
DayGridPlugin,
TimeGridPlugin,
Expand Down
7 changes: 4 additions & 3 deletions packages/__tests__/src/legacy/ListView.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import frLocale from '@fullcalendar/core/locales/fr'
import {
getEmptyMessageElsCount,
getListHeadingElAltElText,
Expand Down Expand Up @@ -148,9 +149,9 @@ describe('ListView rendering', function() {

// regression test for when localized event dates get unlocalized and leak into view rendering
it('renders dates and times in locale', function() {
var options = {}
options.locale = 'fr'
initCalendar(options)
initCalendar({
locale: frLocale
})

var days = getDayInfo()
var events = getEventInfo()
Expand Down
5 changes: 3 additions & 2 deletions packages/__tests__/src/legacy/allDayText.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ptBrLocale from '@fullcalendar/core/locales/pt-br'
import { getAllDayAxisElText } from '../view-render/DayGridRenderUtils'

describe('allDayText', function() {
Expand Down Expand Up @@ -56,7 +57,7 @@ describe('allDayText', function() {
var options = {
defaultView: 'timeGridWeek',
allDaySlot: true,
locale: 'pt-br'
locale: ptBrLocale
}
initCalendar(options)
var allDayText = getAllDayAxisElText()
Expand All @@ -68,7 +69,7 @@ describe('allDayText', function() {
var options = {
defaultView: 'timeGridDay',
allDaySlot: true,
locale: 'pt-br'
locale: ptBrLocale
}
initCalendar(options)
var allDayText = getAllDayAxisElText()
Expand Down
4 changes: 3 additions & 1 deletion packages/__tests__/src/legacy/buttonText.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import frLocale from '@fullcalendar/core/locales/fr'

describe('button text', function() {

pushOptions({
Expand Down Expand Up @@ -115,7 +117,7 @@ describe('button text', function() {
describe('when locale is not default', function() {

pushOptions({
locale: 'fr'
locale: frLocale
})

describe('with default buttonIcons', function() {
Expand Down
9 changes: 6 additions & 3 deletions packages/__tests__/src/legacy/columnHeaderFormat.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import frLocale from '@fullcalendar/core/locales/fr'
import enGbLocale from '@fullcalendar/core/locales/en-gb'
import koLocale from '@fullcalendar/core/locales/ko'

describe('columnHeaderFormat', function() {

Expand Down Expand Up @@ -69,7 +72,7 @@ describe('columnHeaderFormat', function() {
beforeEach(function() {
initCalendar({
defaultDate: '2014-05-11',
locale: 'fr'
locale: frLocale
})
})

Expand All @@ -96,7 +99,7 @@ describe('columnHeaderFormat', function() {
beforeEach(function() {
initCalendar({
defaultDate: '2014-05-11',
locale: 'en-gb'
locale: enGbLocale
})
})

Expand All @@ -123,7 +126,7 @@ describe('columnHeaderFormat', function() {
beforeEach(function() {
initCalendar({
defaultDate: '2014-05-11',
locale: 'ko'
locale: koLocale
})
})

Expand Down
55 changes: 28 additions & 27 deletions packages/__tests__/src/legacy/custom-view-duration.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import frLocale from '@fullcalendar/core/locales/fr'
import { View, createPlugin } from '@fullcalendar/core'

describe('custom view', function() {
Expand Down Expand Up @@ -283,37 +284,37 @@ describe('custom view', function() {
})

it('accepts locale\'s single-unit-match override', function() {
var options = {
views: {}
}
options.locale = 'fr'
options.views.custom = {
type: 'dayGrid',
duration: { days: 1 }
}
options.header = {
center: 'custom,dayGridMonth'
}
options.defaultView = 'custom'
initCalendar(options)
initCalendar({
locale: frLocale,
header: {
center: 'custom,dayGridMonth'
},
defaultView: 'custom',
views: {
custom: {
type: 'dayGrid',
duration: { days: 1 }
}
}
})
expect($('.fc-custom-button')).toHaveText('Jour')
})

it('accepts explicit View-Specific buttonText, overriding locale\'s single-unit-match override', function() {
var options = {
views: {}
}
options.locale = 'fr'
options.views.custom = {
type: 'dayGrid',
duration: { days: 1 },
buttonText: 'awesome'
}
options.header = {
center: 'custom,dayGridMonth'
}
options.defaultView = 'custom'
initCalendar(options)
initCalendar({
locale: frLocale,
header: {
center: 'custom,dayGridMonth'
},
defaultView: 'custom',
views: {
custom: {
type: 'dayGrid',
duration: { days: 1 },
buttonText: 'awesome'
}
}
})
expect($('.fc-custom-button')).toHaveText('awesome')
})

Expand Down
5 changes: 3 additions & 2 deletions packages/__tests__/src/legacy/dayPopoverFormat.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import frLocale from '@fullcalendar/core/locales/fr'
import { getMoreEl, getMorePopoverTitle } from '../view-render/DayGridRenderUtils'

describe('dayPopoverFormat', function() {
Expand All @@ -23,15 +24,15 @@ describe('dayPopoverFormat', function() {

it('is affected by the current locale when the value is default', function() {
initCalendar({
locale: 'fr'
locale: frLocale
})
getMoreEl().simulate('click')
expect(getMorePopoverTitle()).toBe('29 juillet 2014')
})

it('still maintains the same format when explicitly set, and there is a locale', function() {
initCalendar({
locale: 'fr',
locale: frLocale,
dayPopoverFormat: { year: 'numeric' }
})
getMoreEl().simulate('click')
Expand Down
4 changes: 3 additions & 1 deletion packages/__tests__/src/legacy/dir.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import arLocale from '@fullcalendar/core/locales/ar'

describe('dir', function() {

it('has it\'s default value computed differently based off of the locale', function() {
initCalendar({
locale: 'ar' // Arabic is RTL
locale: arLocale // Arabic is RTL
})
expect(currentCalendar.getOption('dir')).toEqual('rtl')
})
Expand Down
6 changes: 4 additions & 2 deletions packages/__tests__/src/legacy/eventLimitText.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import frLocale from '@fullcalendar/core/locales/fr'

describe('eventLimitText', function() {

pushOptions({
Expand Down Expand Up @@ -31,14 +33,14 @@ describe('eventLimitText', function() {

it('has a default value that is affected by the custom locale', function() {
initCalendar({
locale: 'fr'
locale: frLocale
})
expect($('.fc-more')).toHaveText('+2 en plus')
})

it('is not affected by a custom locale when the value is explicitly specified', function() {
initCalendar({
locale: 'fr',
locale: frLocale,
eventLimitText: 'extra'
})
expect($('.fc-more')).toHaveText('+2 extra')
Expand Down
6 changes: 4 additions & 2 deletions packages/__tests__/src/legacy/eventTimeFormat.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import enGbLocale from '@fullcalendar/core/locales/en-gb'

describe('eventTimeFormat', function() {

pushOptions({
Expand Down Expand Up @@ -26,7 +28,7 @@ describe('eventTimeFormat', function() {

it('renders correctly when default and the locale is customized', function() {
initCalendar({
locale: 'en-gb'
locale: enGbLocale
})
expect(getRenderedEventTime()).toBe('15')
})
Expand All @@ -52,7 +54,7 @@ describe('eventTimeFormat', function() {

it('renders correctly when default and the locale is customized', function() {
initCalendar({
locale: 'en-gb'
locale: enGbLocale
})
expect(getRenderedEventTime()).toBe('15:00 - 17:00')
})
Expand Down
3 changes: 2 additions & 1 deletion packages/__tests__/src/legacy/external-dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { Calendar } from '@fullcalendar/core'
import InteractionPlugin, { ThirdPartyDraggable } from '@fullcalendar/interaction'
import DayGridPlugin from '@fullcalendar/daygrid'
import TimeGridPlugin from '@fullcalendar/timegrid'
import 'components-jqueryui' // for .sortable and .draggable

describe('external drag and drop', function() {
describe('external drag and drop with jquery UI', function() {

// TODO: fill out tests for droppable/drop, with RTL

Expand Down
4 changes: 3 additions & 1 deletion packages/__tests__/src/legacy/firstDay.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import enGbLocale from '@fullcalendar/core/locales/en-gb'

describe('First Day', function() {

describe('when using default settings', function() {
Expand Down Expand Up @@ -179,7 +181,7 @@ describe('First Day', function() {

it('should have a different default value based on the locale', function() {
initCalendar({
locale: 'en-gb'
locale: enGbLocale
})
// firstDay will be 1 (Monday) in Great Britain
var daysOfWeek = $('.fc-day-header')
Expand Down
7 changes: 7 additions & 0 deletions packages/__tests__/src/legacy/locale.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import esLocale from '@fullcalendar/core/locales/es'
import frLocale from '@fullcalendar/core/locales/fr'
import arLocale from '@fullcalendar/core/locales/ar'

describe('locale', function() {
pushOptions({
locales: [ esLocale, frLocale, arLocale ]
})

it('works when certain locale has no FC settings defined', function() {
initCalendar({
Expand Down
4 changes: 3 additions & 1 deletion packages/__tests__/src/legacy/slotLabelFormat.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import enGbLocale from '@fullcalendar/core/locales/en-gb'

describe('slotLabelFormat', function() {

pushOptions({
Expand All @@ -16,7 +18,7 @@ describe('slotLabelFormat', function() {

it('renders correctly when default and the locale is customized', function() {
initCalendar({
locale: 'en-gb'
locale: enGbLocale
})
expect(getAxisText()).toBe('00')
})
Expand Down

0 comments on commit 8b26981

Please sign in to comment.