Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('converts numeric values correctly', function() {
let calendar = new Calendar(document.createElement('div'), {
plugins: PLUGINS,
defaultTimedEventDuration: '05:00',
defaultAllDayEventDuration: { days: 3 }
})
// hacky way to have a duration parsed
let timedDuration = toDuration(calendar.defaultTimedEventDuration, calendar)
let allDayDuration = toDuration(calendar.defaultAllDayEventDuration, calendar)
expect(timedDuration.as('hours')).toBe(5)
expect(allDayDuration.as('days')).toBe(3)
})
it('transfers locale correctly', function() {
let calendar = new Calendar(document.createElement('div'), {
plugins: PLUGINS,
defaultTimedEventDuration: '05:00',
locale: esLocale
})
// hacky way to have a duration parsed
let timedDuration = toDuration(calendar.defaultTimedEventDuration, calendar)
expect(timedDuration.locale).toBe('es')
})
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new Calendar(calendarEl, {
plugins: [ interactionPlugin, dayGridPlugin, momentTimezonePlugin ],
timeZone: 'Europe/Madrid',
defaultDate: '2018-01-12',
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: 'All Day Event',
start: '2018-01-01',
},
{
title: 'Long Event',
start: '2018-01-07',
end: '2018-01-10'
},
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new Calendar(calendarEl, {
locale: esLocale,
plugins: [ interactionPlugin, dayGridPlugin, timeGridPlugin, listPlugin ],
header: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
},
defaultDate: '2018-01-12',
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: 'All Day Event',
start: '2018-01-01',
},
document.addEventListener('DOMContentLoaded', function() {
let calendarEl: HTMLElement = document.getElementById('calendar')!;
let calendar = new Calendar(calendarEl, {
plugins: [ interactionPlugin, dayGridPlugin, timeGridPlugin, listPlugin ],
header: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
},
defaultDate: '2018-01-12',
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: 'All Day Event',
start: '2018-01-01',
},
{
it('fires all triggers', function(done) {
let triggerNames = []
let eventAllowCalled = false
calendar0 = new Calendar(el0, {
plugins: [ InteractionPlugin, DayGridPlugin ],
timeZone: 'UTC',
defaultDate: DEFAULT_DATE,
defaultView: 'dayGridMonth',
editable: true,
events: [
{ start: '2019-01-01', id: 'a' }
],
eventLeave: function(info) {
triggerNames.push('eventLeave')
expect(info.draggedEl).toBe(eventEl)
expect(info.event.id).toBe('a')
}
})
calendar1 = new Calendar(el1, {
it('will fire on a calendar that hasn\'t been rendered yet', function(done) {
let calendar = new Calendar(
document.createElement('div'),
{
plugins: [ InteractionPlugin, DayGridPlugin ],
now: '2018-12-25',
select: function(info) {
expect(info.startStr).toBe('2018-12-20')
expect(info.endStr).toBe('2018-12-23')
done()
}
}
)
calendar.select('2018-12-20', '2018-12-23')
})
})
it('renders with different years', function() {
let calendar = new Calendar(document.createElement('div'), {
plugins: PLUGINS
})
let s
s = calendar.formatRange('2018-09-03', '2019-10-05', '{MMMM {d}}, yyyy \'asdf\'')
expect(s).toEqual('September 3, 2018 asdf - October 5, 2019 asdf')
s = calendar.formatRange('2018-09-03', '2019-10-05', '{{d} MMMM}, yyyy \'asdf\'')
expect(s).toEqual('3 September, 2018 asdf - 5 October, 2019 asdf')
})
initialize() {
this.calendar = new Calendar(this.el.nativeElement.children[0], this.config);
this.calendar.render();
this.initialized = true;
if (this.events) {
this.calendar.removeAllEventSources();
this.calendar.addEventSource(this.events);
}
}