initial Commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
isDialogLaunch,
|
||||
isNewTabLaunch,
|
||||
normalizeColumns,
|
||||
normalizeImageUrl,
|
||||
normalizeNavigationUrl,
|
||||
normalizeTileHeight
|
||||
} from '../src/webparts/modernPromotedLinks/PromotedLinkCore';
|
||||
|
||||
declare const console: { log(message: string): void };
|
||||
|
||||
let passed: number = 0;
|
||||
function assert(condition: boolean, message: string): void {
|
||||
if (!condition) { throw new Error(message); }
|
||||
passed++;
|
||||
}
|
||||
|
||||
const webUrl: string = 'http://portal.contoso.local/sites/demo';
|
||||
assert(normalizeNavigationUrl('Pages/Start.aspx', webUrl) === webUrl + '/Pages/Start.aspx', 'Relative links must be resolved.');
|
||||
assert(normalizeNavigationUrl('/sites/demo', webUrl) === '/sites/demo', 'Server-relative links must be retained.');
|
||||
assert(normalizeNavigationUrl('mailto:test@example.com', webUrl) === 'mailto:test@example.com', 'Mail links must be supported.');
|
||||
assert(normalizeNavigationUrl('javascript:alert(1)', webUrl) === '', 'JavaScript URLs must be rejected.');
|
||||
assert(normalizeNavigationUrl('data:text/html,test', webUrl) === '', 'Data URLs must be rejected.');
|
||||
assert(normalizeImageUrl('mailto:test@example.com', webUrl) === '', 'Special navigation URLs must not be accepted as images.');
|
||||
assert(normalizeImageUrl('/SiteAssets/tile.jpg', webUrl) === '/SiteAssets/tile.jpg', 'Server-relative image URLs must be retained.');
|
||||
assert(isNewTabLaunch('New tab'), 'New tab launch behavior must be recognized.');
|
||||
assert(isNewTabLaunch('New window'), 'New window launch behavior must be recognized.');
|
||||
assert(isDialogLaunch('Dialog'), 'Dialog launch behavior must be recognized.');
|
||||
assert(normalizeColumns(9) === 6 && normalizeColumns(0) === 4, 'Column values must be normalized.');
|
||||
assert(normalizeTileHeight(80) === 120 && normalizeTileHeight(400) === 320, 'Tile height must be normalized.');
|
||||
|
||||
console.log('Promoted link core tests passed: ' + passed);
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../temp/tests",
|
||||
"rootDir": "..",
|
||||
"lib": ["es5", "dom", "es2015.promise"],
|
||||
"types": [],
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"files": [
|
||||
"../src/webparts/modernPromotedLinks/PromotedLinkCore.ts",
|
||||
"PromotedLinkCore.test.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
'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 solution = packageSolution.solution;
|
||||
var config = json('config/config.json');
|
||||
var manifest = json('src/webparts/modernPromotedLinks/ModernPromotedLinksWebPart.manifest.json');
|
||||
var webPart = read('src/webparts/modernPromotedLinks/ModernPromotedLinksWebPart.ts');
|
||||
var service = read('src/webparts/modernPromotedLinks/PromotedLinksDataService.ts');
|
||||
var component = read('src/webparts/modernPromotedLinks/components/ModernPromotedLinks.tsx');
|
||||
var core = read('src/webparts/modernPromotedLinks/PromotedLinkCore.ts');
|
||||
var styles = read('src/webparts/modernPromotedLinks/components/ModernPromotedLinks.module.scss');
|
||||
|
||||
assert(packageJson.name === 'modern-promoted-link-list-webpart', 'npm package name is inconsistent.');
|
||||
assert(solution.name === packageJson.name && solution.title === packageJson.name, 'Solution naming is inconsistent.');
|
||||
assert(packageSolution.paths.zippedPackage === 'solution/modern-promoted-link-list-webpart.sppkg', 'Package file name is inconsistent.');
|
||||
assert(solution.includeClientSideAssets === true && solution.skipFeatureDeployment === true, 'Central asset deployment is not configured.');
|
||||
assert(manifest.componentType === 'WebPart' && manifest.alias === 'ModernPromotedLinksWebPart', 'WebPart manifest is invalid.');
|
||||
assert(!!config.bundles['modern-promoted-link-list-webpart'], 'Bundle name is inconsistent.');
|
||||
assert(service.indexOf('BaseTemplate eq 170') >= 0, 'Promoted Links list filtering is missing.');
|
||||
['BackgroundImageLocation', 'LinkLocation', 'LaunchBehavior', 'TileOrder'].forEach(function(field) {
|
||||
assert(service.indexOf(field) >= 0, 'Classic Promoted Links field is missing: ' + field);
|
||||
});
|
||||
assert(webPart.indexOf("PropertyPaneDropdown('listId'") >= 0, 'List picker is missing.');
|
||||
assert(webPart.indexOf("PropertyPaneSlider('columns'") >= 0 && webPart.indexOf("PropertyPaneSlider('tileHeight'") >= 0,
|
||||
'Layout controls are missing.');
|
||||
assert(component.indexOf("role='list'") >= 0 && component.indexOf('aria-label={label}') >= 0, 'Accessible list semantics are missing.');
|
||||
assert(core.indexOf("/^[a-z][a-z0-9+.-]*:/i") >= 0, 'Unsafe URL schemes are not rejected.');
|
||||
['bodyText', 'themePrimary', 'focusBorder', 'errorText'].forEach(function(slot) {
|
||||
assert(styles.indexOf('[theme:' + slot + ', default:') >= 0, 'SharePoint theme slot is missing: ' + slot);
|
||||
});
|
||||
|
||||
console.log('Modern Promoted Link List project validation passed: ' + passed);
|
||||
Reference in New Issue
Block a user