mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-17 23:34:50 +00:00
Add a test for custom action widgets
This commit is contained in:
parent
0e4e037bb7
commit
66d4b07f7e
@ -0,0 +1,28 @@
|
|||||||
|
title: Ubertransclude/CustomWidget/ActionWidget
|
||||||
|
description: Custom widget definition
|
||||||
|
type: text/vnd.tiddlywiki-multiple
|
||||||
|
tags: [[$:/tags/wiki-test-spec]]
|
||||||
|
|
||||||
|
title: Output
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
|
<$ubertransclude $tiddler='Result'>
|
||||||
|
</$ubertransclude>
|
||||||
|
_
|
||||||
|
title: Actions
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
|
<!-- Define the <$action-mywidget> widget by defining a transcludable variable with that name -->
|
||||||
|
<$set name="<$action-mywidget>" value="""\whitespace trim
|
||||||
|
<$parameters one='Jaguar'>
|
||||||
|
<$action-setfield $tiddler="Result" $field="text" $value=<<one>>/>
|
||||||
|
</$parameters>"""
|
||||||
|
>
|
||||||
|
<$action-mywidget one="Dingo">
|
||||||
|
Crocodile
|
||||||
|
</$action-mywidget>
|
||||||
|
</$set>
|
||||||
|
_
|
||||||
|
title: ExpectedResult
|
||||||
|
|
||||||
|
<p>Dingo</p>
|
@ -38,6 +38,11 @@ describe("Wiki-based tests", function() {
|
|||||||
var widgetNode = createWidgetNode(parseText(text,wiki),wiki);
|
var widgetNode = createWidgetNode(parseText(text,wiki),wiki);
|
||||||
// Render the widget node to the DOM
|
// Render the widget node to the DOM
|
||||||
var wrapper = renderWidgetNode(widgetNode);
|
var wrapper = renderWidgetNode(widgetNode);
|
||||||
|
// Run the actions if provided
|
||||||
|
if(wiki.tiddlerExists("Actions")) {
|
||||||
|
widgetNode.invokeActionString(wiki.getTiddlerText("Actions"));
|
||||||
|
refreshWidgetNode(widgetNode,wrapper);
|
||||||
|
}
|
||||||
// Test the rendering
|
// Test the rendering
|
||||||
expect(wrapper.innerHTML).toBe(wiki.getTiddlerText("ExpectedResult"));
|
expect(wrapper.innerHTML).toBe(wiki.getTiddlerText("ExpectedResult"));
|
||||||
});
|
});
|
||||||
@ -80,14 +85,8 @@ describe("Wiki-based tests", function() {
|
|||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshWidgetNode(widgetNode,wrapper,changes) {
|
function refreshWidgetNode(widgetNode,wrapper) {
|
||||||
var changedTiddlers = {};
|
widgetNode.refresh(widgetNode.wiki.changedTiddlers,wrapper);
|
||||||
if(changes) {
|
|
||||||
$tw.utils.each(changes,function(title) {
|
|
||||||
changedTiddlers[title] = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
widgetNode.refresh(changedTiddlers,wrapper,null);
|
|
||||||
// console.log(require("util").inspect(wrapper,{depth: 8}));
|
// console.log(require("util").inspect(wrapper,{depth: 8}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user