@pega/custom-dx-components
Version:
Utility for building custom UI components
38 lines (31 loc) • 1.5 kB
JavaScript
import { jest, expect, test, describe } from '@jest/globals';
jest.mock('../../src/util.js', () => ({
getComponentDirectoryPath: jest.fn(),
getComponents: jest.fn(),
isComponentValidLength: jest.fn(() => true),
getConfigDefaults: jest.fn(() => ({ currentOrgLib: 'Org_Lib' })),
getLibraryBasedCL: jest.fn(() => false)
}));
import { validatePresentationSubtype } from '../../src/tasks/validator/index.js';
describe('validatePresentationSubtype', () => {
test('passes for Presentation type with CASEVIEW subtype', () => {
expect(() =>
validatePresentationSubtype({ name: 'Org_Lib_MyCaseView', type: 'Presentation', subtype: 'CASEVIEW' })
).not.toThrow();
});
test('passes for Presentation type with WSSCASEVIEW subtype', () => {
expect(() =>
validatePresentationSubtype({ name: 'Org_Lib_MyWSSCaseView', type: 'Presentation', subtype: 'WSSCASEVIEW' })
).not.toThrow();
});
test('throws for Presentation type with a non-presentation subtype', () => {
expect(() =>
validatePresentationSubtype({ name: 'Org_Lib_Bad', type: 'Presentation', subtype: 'SimpleInput' })
).toThrow(/Invalid subtype 'SimpleInput' for Presentation component/);
});
test('throws when a presentation-only subtype is used on a non-Presentation type', () => {
expect(() =>
validatePresentationSubtype({ name: 'Org_Lib_Bad', type: 'Field', subtype: 'CASEVIEW' })
).toThrow(/Subtype 'CASEVIEW' is only allowed for Presentation components/);
});
});