Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,33 @@ describe('Appointment Form', () => {
);
});

it('should render FontAwesome icon with correct CSS classes (T1322161)', async () => {
const { scheduler } = await createScheduler({
...getDefaultConfig(),
dataSource: [{
text: 'Resource test app',
startDate: new Date(2017, 4, 9, 9, 30),
endDate: new Date(2017, 4, 9, 11),
roomId: 1,
}],
resources: [{
fieldExpr: 'roomId',
icon: 'fas fa-home',
dataSource: [{ text: 'Room 1', id: 1 }, { text: 'Room 2', id: 2 }],
}],
});
const dataSource = (scheduler as any).getDataSource();
const appointment = dataSource.items()[0];

scheduler.showAppointmentPopup(appointment);

const $iconElement = $('.dx-scheduler-form-resources-group .dx-icon');

expect($iconElement.length).toBe(1);
expect($iconElement.hasClass('fas')).toBe(true);
expect($iconElement.hasClass('fa-home')).toBe(true);
});

it('should create dxTagBox for resource with multiple selection', async () => {
const { scheduler, POM } = await createScheduler({
...getDefaultConfig(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { describe, expect, it } from '@jest/globals';

import { createFormIconTemplate } from './utils';

describe('createFormIconTemplate', () => {
describe('FontAwesome icons support', () => {
it('should create icon element with FontAwesome classes', () => {
const template = createFormIconTemplate('fas fa-home');
const $icon = template();

expect($icon.hasClass('dx-icon')).toBe(true);
expect($icon.hasClass('fas')).toBe(true);
expect($icon.hasClass('fa-home')).toBe(true);
});

it('should create icon element with FontAwesome solid icon', () => {
const template = createFormIconTemplate('fa-solid fa-user');
const $icon = template();

expect($icon.hasClass('dx-icon')).toBe(true);
expect($icon.hasClass('fa-solid')).toBe(true);
expect($icon.hasClass('fa-user')).toBe(true);
});
});

describe('DevExtreme icons support', () => {
it('should create icon element with DevExtreme icon class', () => {
const template = createFormIconTemplate('tags');
const $icon = template();

expect($icon.hasClass('dx-icon')).toBe(true);
expect($icon.hasClass('dx-icon-tags')).toBe(true);
});
});

describe('empty icon', () => {
it('should create sized gap element when icon name is empty', () => {
const template = createFormIconTemplate('');
const $element = template();

expect($element.hasClass('dx-scheduler-form-icon-sized-gap')).toBe(true);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ import { isDefined } from '@js/core/utils/type';
import type { Properties as DateBoxProperties } from '@js/ui/date_box';
import type { SimpleItem } from '@js/ui/form';

import { getImageContainer } from '../../core/utils/m_icon';
import { getRecurrenceString, parseRecurrenceRule } from '../recurrence/base';
import { daysFromByDayRule } from '../recurrence/days_from_by_day_rule';
import type { Rule } from '../recurrence/types';

export const createFormIconTemplate = (iconName: string): () => dxElementWrapper => {
if (iconName.length === 0) {
return (): dxElementWrapper => $('<div>').addClass('dx-scheduler-form-icon-sized-gap');
}

return (): dxElementWrapper => $('<i>').addClass('dx-icon').addClass(`dx-icon-${iconName}`);
};
export const createFormIconTemplate = (iconName: string): () => dxElementWrapper => (): dxElementWrapper => getImageContainer(iconName) ?? $('<div>').addClass('dx-scheduler-form-icon-sized-gap');

export const getStartDateCommonConfig = (firstDayOfWeek: string): SimpleItem => ({
colSpan: 1,
Expand Down
Loading