Skip to content

Commit

Permalink
test dont autoload some plugins. use technique in luxon plugin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Jan 29, 2019
1 parent 09739a2 commit c0ed41a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
23 changes: 16 additions & 7 deletions tests/automated/datelib/luxon.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Calendar } from '@fullcalendar/core'
import { toDateTime, toDuration } from '@fullcalendar/luxon'
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'
Expand All @@ -12,6 +13,9 @@ if (!luxon) {
luxon &&
describe('luxon plugin', function() {

const PLUGINS = [ LuxonPlugin, DayGridPlugin ]
pushOptions({ plugins: PLUGINS })

testTimeZoneImpl('luxon')

describe('toDateTime', function() {
Expand All @@ -20,6 +24,7 @@ describe('luxon plugin', function() {

it('transfers UTC', function() {
let calendar = new Calendar(document.createElement('div'), {
plugins: PLUGINS,
events: [ { start: '2018-09-05T12:00:00', end: '2018-09-05T18:00:00' } ],
timeZone: 'UTC'
})
Expand All @@ -34,6 +39,7 @@ describe('luxon plugin', function() {

it('transfers local timezone', function() {
let calendar = new Calendar(document.createElement('div'), {
plugins: PLUGINS,
events: [ { start: '2018-09-05T12:00:00', end: '2018-09-05T18:00:00' } ],
timeZone: 'local'
})
Expand All @@ -48,6 +54,7 @@ describe('luxon plugin', function() {

it('transfers named timezone', function() {
let calendar = new Calendar(document.createElement('div'), {
plugins: PLUGINS,
events: [ { start: '2018-09-05T12:00:00', end: '2018-09-05T18:00:00' } ],
timeZone: 'Europe/Moscow'
})
Expand All @@ -64,6 +71,7 @@ describe('luxon plugin', function() {

it('transfers locale', 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'
})
Expand All @@ -78,6 +86,7 @@ describe('luxon plugin', function() {

it('converts numeric values correctly', function() {
let calendar = new Calendar(document.createElement('div'), {
plugins: PLUGINS,
defaultTimedEventDuration: '05:00',
defaultAllDayEventDuration: { days: 3 }
})
Expand All @@ -92,6 +101,7 @@ describe('luxon plugin', function() {

it('transfers locale correctly', function() {
let calendar = new Calendar(document.createElement('div'), {
plugins: PLUGINS,
defaultTimedEventDuration: '05:00',
locale: 'es'
})
Expand All @@ -111,7 +121,6 @@ describe('luxon plugin', function() {
defaultView: 'month',
now: '2018-09-06',
displayEventEnd: false,
cmdFormatter: 'luxon',
eventTimeFormat: 'HH:mm:ss\'abc\'',
events: [
{ title: 'my event', start: '2018-09-06T13:30:20' }
Expand All @@ -126,7 +135,7 @@ describe('luxon plugin', function() {

it('renders with same month', function() {
let calendar = new Calendar(document.createElement('div'), {
cmdFormatter: 'luxon'
plugins: PLUGINS
})
let s

Expand All @@ -139,7 +148,7 @@ describe('luxon plugin', function() {

it('renders with same year but different month', function() {
let calendar = new Calendar(document.createElement('div'), {
cmdFormatter: 'luxon'
plugins: PLUGINS
})
let s

Expand All @@ -152,7 +161,7 @@ describe('luxon plugin', function() {

it('renders with different years', function() {
let calendar = new Calendar(document.createElement('div'), {
cmdFormatter: 'luxon'
plugins: PLUGINS
})
let s

Expand All @@ -165,7 +174,7 @@ describe('luxon plugin', function() {

it('inherits defaultRangeSeparator', function() {
let calendar = new Calendar(document.createElement('div'), {
cmdFormatter: 'luxon',
plugins: PLUGINS,
defaultRangeSeparator: ' to '
})
let s = calendar.formatRange('2018-09-03', '2018-09-05', 'MMMM d, yyyy \'asdf\'')
Expand All @@ -174,9 +183,9 @@ describe('luxon plugin', function() {

it('produces title with titleRangeSeparator', function() {
initCalendar({ // need to render the calendar to get view.title :(
plugins: PLUGINS,
defaultView: 'basicWeek',
now: '2018-09-06',
cmdFormatter: 'luxon',
titleFormat: 'MMMM {d} yy \'yup\'',
titleRangeSeparator: ' to '
})
Expand Down
20 changes: 19 additions & 1 deletion tests/automated/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import './hacks'
import './lib/simulate'
import './lib/date-matchers'
import { Calendar, globalDefaults } from '@fullcalendar/core'
import InteractionPlugin from '@fullcalendar/interaction'
import DayGridPlugin from '@fullcalendar/daygrid'
import TimeGridPlugin from '@fullcalendar/timegrid'
import ListPlugin from '@fullcalendar/list'

const DEFAULT_PLUGINS = [
InteractionPlugin,
DayGridPlugin,
TimeGridPlugin,
ListPlugin
]


// Setup / Teardown
// ---------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -84,7 +96,13 @@ function initCalendar(moreOptions, el) {
}

function getCurrentOptions() {
return $.extend.apply($, [ {} ].concat(optionsStack))
let options = $.extend.apply($, [ {} ].concat(optionsStack))

if (!options.plugins) {
options.plugins = DEFAULT_PLUGINS
}

return options
}


Expand Down
2 changes: 2 additions & 0 deletions tests/automated/hacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ beforeEach(function() {
// The simulates touch events do not fire these mouse events anyway.
globalHooks.touchMouseIgnoreWait = 0

globalHooks.disableGlobalPlugins = true

// increase the default timeout
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000

Expand Down

0 comments on commit c0ed41a

Please sign in to comment.