Files
Modern-Recurring-Events/tests/validate-project.js
T

48 lines
3.3 KiB
JavaScript

'use strict';
var fs = require('fs');
var path = require('path');
var root = path.resolve(__dirname, '..');
var passed = 0;
function read(file) { return fs.readFileSync(path.join(root, file), 'utf8'); }
function json(file) { return JSON.parse(read(file)); }
function assert(condition, message) { if (!condition) { throw new Error(message); } passed++; }
var packageJson = json('package.json');
var packageSolution = json('config/package-solution.json');
var config = json('config/config.json');
var manifest = json('src/webparts/recurringEvents/RecurringEventsWebPart.manifest.json');
var service = read('src/webparts/recurringEvents/RecurringEventsDataService.ts');
var webPart = read('src/webparts/recurringEvents/RecurringEventsWebPart.ts');
var component = read('src/webparts/recurringEvents/components/RecurringEvents.tsx');
var styles = read('src/webparts/recurringEvents/components/RecurringEvents.module.scss');
assert(packageJson.name === 'modern-recurring-events-webpart', 'Package name is inconsistent.');
assert(packageSolution.solution.name === packageJson.name && packageSolution.solution.title === packageJson.name,
'Solution name is inconsistent.');
assert(packageSolution.paths.zippedPackage === 'solution/modern-recurring-events-webpart.sppkg', 'Package file name is inconsistent.');
assert(packageSolution.solution.includeClientSideAssets === true && packageSolution.solution.skipFeatureDeployment === true,
'Central deployment is not configured.');
assert(!!config.bundles['modern-recurring-events-webpart'], 'Bundle name is inconsistent.');
assert(manifest.componentType === 'WebPart' && manifest.alias === 'RecurringEventsWebPart', 'Manifest is invalid.');
assert(webPart.indexOf("String(this.properties.title || '').trim()") >= 0 &&
component.indexOf('this.props.title &&') >= 0, 'An empty web part title must remain hidden.');
assert(service.indexOf('BaseTemplate eq 106') >= 0, 'Events-list filtering is missing.');
assert(service.indexOf('<ExpandRecurrence>TRUE</ExpandRecurrence>') >= 0, 'Server-side recurrence expansion is missing.');
assert(service.indexOf('<CalendarDate>') >= 0 && service.indexOf('<Month/>') >= 0, 'Calendar month expansion is incomplete.');
assert(service.indexOf('MasterSeriesItemID') >= 0 && service.indexOf('RecurrenceID') >= 0, 'Series metadata is missing.');
assert(webPart.indexOf("{ key: 'filmstrip'") >= 0 && webPart.indexOf("{ key: 'compact'") >= 0,
'Filmstrip and compact layouts are not configurable.');
assert(webPart.indexOf("PropertyPaneDropdown('category'") >= 0 && webPart.indexOf("PropertyPaneDropdown('rangeDays'") >= 0,
'Event filtering controls are missing.');
assert(component.indexOf("role='list'") >= 0 && component.indexOf('aria-label={this.eventLabel(event)}') >= 0,
'Accessible event semantics are missing.');
assert(component.indexOf('newEventUrl') >= 0 && component.indexOf('seeAllUrl') >= 0,
'New Event and See All commands are missing.');
assert(webPart.indexOf('list.defaultNewFormUrl') >= 0 && webPart.indexOf('list.defaultViewUrl') >= 0,
'Event-list command URLs are missing.');
['bodyText', 'white', 'neutralLight', 'themePrimary', 'themeDark', 'focusBorder', 'errorText'].forEach(function(slot) {
assert(styles.indexOf('[theme:' + slot + ', default:') >= 0, 'SharePoint theme slot is missing: ' + slot);
});
console.log('Modern Recurring Events project validation passed: ' + passed);