PHP Classes

File: tests/js/scheduler-integration.test.js

Recommend this page to a friend!
  Packages of Boss Ibrahim Mussa   Caelrik   tests/js/scheduler-integration.test.js   Download  
File: tests/js/scheduler-integration.test.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Caelrik
Build Web user interface from PHP components
Author: By
Last change:
Date: 8 days ago
Size: 2,844 bytes
 

 

Contents

Class file image Download
import axe from 'axe-core'; import { initScheduler } from '../../resources/js/scheduler.js'; import { readOptions } from '../../resources/js/core.js'; import { loadFixture } from './helpers.js'; describe('scheduler integration (FullCalendar)', () => { test('replaces the fallback list with a calendar showing the events', () => { const element = loadFixture('scheduler'); expect(element.querySelector('.caelrik-scheduler__fallback')).not.toBeNull(); const calendar = initScheduler(element, readOptions(element)); expect(element.querySelector('.caelrik-scheduler__fallback')).toBeNull(); expect(element.classList.contains('fc')).toBe(true); expect(calendar.view.type).toBe('listWeek'); expect(calendar.getEvents().map((event) => event.title)).toEqual(['Kick-off', 'Design review', 'Holiday']); expect([...element.querySelectorAll('.fc-list-event-title')].map((td) => td.textContent)) .toEqual(['Kick-off', 'Design review', 'Holiday']); calendar.destroy(); }); test.each(['listWeek', 'dayGridMonth', 'timeGridWeek'])('%s view has no WCAG 2.1 A/AA violations', async (view) => { const element = loadFixture('scheduler'); const calendar = initScheduler(element, readOptions(element)); calendar.changeView(view); const results = await axe.run(document.body, { runOnly: { type: 'tag', values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'] }, rules: { 'color-contrast': { enabled: false } }, }); expect(results.violations.map((v) => `${v.id}: ${v.nodes.map((n) => n.target.join(' ')).join(', ')}`)).toEqual([]); expect(element.querySelectorAll('.fc-icon[role="img"]:not([aria-hidden="true"])')).toHaveLength(0); calendar.destroy(); }, 30000); // axe needs several seconds on the month and week grids in jsdom test('month view cells are not named by their day number alone', () => { const element = loadFixture('scheduler'); const dayCellDidMount = jest.fn(); const calendar = initScheduler(element, { ...readOptions(element), options: { dayCellDidMount } }); calendar.changeView('dayGridMonth'); const cells = element.querySelectorAll('td.fc-daygrid-day'); expect(cells.length).toBeGreaterThan(27); expect(element.querySelectorAll('td.fc-daygrid-day[aria-labelledby]')).toHaveLength(0); expect(element.querySelector('.fc-daygrid-day-number').getAttribute('aria-label')).toMatch(/2026/); expect(dayCellDidMount).toHaveBeenCalled(); calendar.destroy(); }); test('a user datesSet callback from PHP options still runs', () => { const element = loadFixture('scheduler'); const datesSet = jest.fn(); const calendar = initScheduler(element, { ...readOptions(element), options: { datesSet } }); calendar.next(); expect(datesSet).toHaveBeenCalledTimes(2); calendar.destroy(); }); });