1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-24 22:33:16 +00:00

Fix plugin tests in the browser

This commit is contained in:
Jeremy Ruston 2024-05-21 11:26:24 +01:00
parent 5aa3646df5
commit 4d2aa1dc95

View File

@ -12,33 +12,36 @@ Tests for integrity of the core plugins, languages, themes and editions
/*global $tw: false */ /*global $tw: false */
"use strict"; "use strict";
describe("Plugin tests", function() { if($tw.node) {
// Get all the plugins as a hashmap by title of a JSON string with the plugin content describe("Plugin tests", function() {
var tiddlers = $tw.utils.getAllPlugins();
// console.log(JSON.stringify(Object.keys(tiddlers),null,4)); // Get all the plugins as a hashmap by title of a JSON string with the plugin content
describe("every plugin should have the required standard fields", function() { var tiddlers = $tw.utils.getAllPlugins();
var titles = Object.keys(tiddlers); // console.log(JSON.stringify(Object.keys(tiddlers),null,4));
$tw.utils.each(titles,function(title) { describe("every plugin should have the required standard fields", function() {
it("plugin " + title + " should have the required standard fields",function() { var titles = Object.keys(tiddlers);
var fields = tiddlers[title]; $tw.utils.each(titles,function(title) {
expect(fields["plugin-type"]).toMatch(/^(?:plugin|language|theme)$/); it("plugin " + title + " should have the required standard fields",function() {
switch(fields["plugin-type"]) { var fields = tiddlers[title];
case "plugin": expect(fields["plugin-type"]).toMatch(/^(?:plugin|language|theme)$/);
expect(!!(fields.name && fields.description && fields.list)).toEqual(true); switch(fields["plugin-type"]) {
expect(fields.stability).toMatch(/^(?:STABILITY_0_DEPRECATED|STABILITY_1_EXPERIMENTAL|STABILITY_2_STABLE|STABILITY_3_LEGACY)$/); case "plugin":
break; expect(!!(fields.name && fields.description && fields.list)).toEqual(true);
case "language": expect(fields.stability).toMatch(/^(?:STABILITY_0_DEPRECATED|STABILITY_1_EXPERIMENTAL|STABILITY_2_STABLE|STABILITY_3_LEGACY)$/);
expect(!!(fields.name && fields.description)).toEqual(true); break;
break; case "language":
case "theme": expect(!!(fields.name && fields.description)).toEqual(true);
expect(!!(fields.name && fields.description)).toEqual(true); break;
break; case "theme":
} expect(!!(fields.name && fields.description)).toEqual(true);
break;
}
});
}); });
}); });
}); });
}
});
})(); })();