From 4d2aa1dc95af97241dde860404ea0e000934c04e Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Tue, 21 May 2024 11:26:24 +0100 Subject: [PATCH] Fix plugin tests in the browser --- editions/test/tiddlers/tests/test-plugins.js | 49 +++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/editions/test/tiddlers/tests/test-plugins.js b/editions/test/tiddlers/tests/test-plugins.js index e045e8928..29ba4a829 100644 --- a/editions/test/tiddlers/tests/test-plugins.js +++ b/editions/test/tiddlers/tests/test-plugins.js @@ -12,33 +12,36 @@ Tests for integrity of the core plugins, languages, themes and editions /*global $tw: false */ "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 - var tiddlers = $tw.utils.getAllPlugins(); - // console.log(JSON.stringify(Object.keys(tiddlers),null,4)); - describe("every plugin should have the required standard fields", function() { - var titles = Object.keys(tiddlers); - $tw.utils.each(titles,function(title) { - it("plugin " + title + " should have the required standard fields",function() { - var fields = tiddlers[title]; - expect(fields["plugin-type"]).toMatch(/^(?:plugin|language|theme)$/); - switch(fields["plugin-type"]) { - case "plugin": - expect(!!(fields.name && fields.description && fields.list)).toEqual(true); - expect(fields.stability).toMatch(/^(?:STABILITY_0_DEPRECATED|STABILITY_1_EXPERIMENTAL|STABILITY_2_STABLE|STABILITY_3_LEGACY)$/); - break; - case "language": - expect(!!(fields.name && fields.description)).toEqual(true); - break; - case "theme": - expect(!!(fields.name && fields.description)).toEqual(true); - break; - } + describe("Plugin tests", function() { + + // Get all the plugins as a hashmap by title of a JSON string with the plugin content + var tiddlers = $tw.utils.getAllPlugins(); + // console.log(JSON.stringify(Object.keys(tiddlers),null,4)); + describe("every plugin should have the required standard fields", function() { + var titles = Object.keys(tiddlers); + $tw.utils.each(titles,function(title) { + it("plugin " + title + " should have the required standard fields",function() { + var fields = tiddlers[title]; + expect(fields["plugin-type"]).toMatch(/^(?:plugin|language|theme)$/); + switch(fields["plugin-type"]) { + case "plugin": + expect(!!(fields.name && fields.description && fields.list)).toEqual(true); + expect(fields.stability).toMatch(/^(?:STABILITY_0_DEPRECATED|STABILITY_1_EXPERIMENTAL|STABILITY_2_STABLE|STABILITY_3_LEGACY)$/); + break; + case "language": + expect(!!(fields.name && fields.description)).toEqual(true); + break; + case "theme": + expect(!!(fields.name && fields.description)).toEqual(true); + break; + } + }); }); }); }); +} -}); })();