1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-12 21:43:01 +00:00

Minor improvement to unit tests

This commit is contained in:
Robin Munn
2022-03-25 12:29:19 +07:00
parent 88854720f5
commit b4e512760e

View File

@@ -827,26 +827,24 @@ describe("Widget module", function() {
* Test data for checkbox widget tests * Test data for checkbox widget tests
*/ */
const checkboxTestTiddlers = [
{title: "TiddlerOne", text: "Jolly Old World", expand: "yes"},
{title: "TiddlerTwo", text: "Jolly Old World", expand: "no"},
];
const checkboxTestData = [ const checkboxTestData = [
{ {
testName: "field mode checked", testName: "field mode checked",
tiddlers: [{title: "TiddlerOne", text: "Jolly Old World", expand: "yes"}],
widgetText: "<$checkbox tiddler='TiddlerOne' field='expand' checked='yes' />", widgetText: "<$checkbox tiddler='TiddlerOne' field='expand' checked='yes' />",
startsOutChecked: true, startsOutChecked: true,
expectedChange: { "TiddlerOne": { expand: undefined } } expectedChange: { "TiddlerOne": { expand: undefined } }
}, },
{ {
testName: "field mode unchecked", testName: "field mode unchecked",
tiddlers: [{title: "TiddlerTwo", text: "Jolly Old World", expand: "no"}],
widgetText: "<$checkbox tiddler='TiddlerTwo' field='expand' unchecked='no' />", widgetText: "<$checkbox tiddler='TiddlerTwo' field='expand' unchecked='no' />",
startsOutChecked: false, startsOutChecked: false,
expectedChange: { "TiddlerTwo": { expand: undefined } } expectedChange: { "TiddlerTwo": { expand: undefined } }
}, },
{ {
testName: "field mode toggle", testName: "field mode toggle",
tiddlers: [{title: "TiddlerTwo", text: "Jolly Old World", expand: "no"}],
widgetText: "<$checkbox tiddler='TiddlerTwo' field='expand' checked='yes' unchecked='no' />", widgetText: "<$checkbox tiddler='TiddlerTwo' field='expand' checked='yes' unchecked='no' />",
startsOutChecked: false, startsOutChecked: false,
expectedChange: { "TiddlerTwo": { expand: "yes" } } expectedChange: { "TiddlerTwo": { expand: "yes" } }
@@ -1063,8 +1061,7 @@ describe("Widget module", function() {
// Create the wiki // Create the wiki
var wiki = new $tw.Wiki(); var wiki = new $tw.Wiki();
// Add test tiddlers // Add test tiddlers
wiki.addTiddlers(checkboxTestTiddlers); wiki.addTiddlers(data.tiddlers);
if(data.tiddlers) wiki.addTiddlers(data.tiddlers);
// Construct the widget node // Construct the widget node
var widgetNode = createWidgetNode(parseText(data.widgetText,wiki),wiki); var widgetNode = createWidgetNode(parseText(data.widgetText,wiki),wiki);
// Render the widget node to the DOM // Render the widget node to the DOM