1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-08-21 13:25:36 +00:00

WIP make all tests pass -- They need to be verified again!

This commit is contained in:
pmario 2024-02-17 04:33:06 +01:00
parent 75b041e562
commit d33ee0bacb
66 changed files with 258 additions and 232 deletions

View File

@ -19,8 +19,7 @@ title: Output
+
title: ExpectedResult
<p>
This is a Elephant, I think.
</p><p>
This is a , I think.
</p>

View File

@ -19,8 +19,7 @@ title: Output
+
title: ExpectedResult
<p>
This is a Elephant, I think.
</p><p>
This is a Crocodile, I think.
</p>

View File

@ -23,10 +23,9 @@ title: Output
+
title: ExpectedResult
<p>
This is a Elephant, I think.
</p><p>
This is a Antelope, I think.
</p><p>
This is a Crocodile, I think.
</p>

View File

@ -19,8 +19,7 @@ title: Output
+
title: ExpectedResult
<p>
This is a Elephant
</p><p>
This is a
</p>

View File

@ -47,14 +47,13 @@ title: Output
+
title: ExpectedResult
<p>
This is a Indian Elephant, I think.
</p><p>
This is a African Elephant, I think.
</p><p>
This is a Unknown Elephant, I think.
</p><p>
This is a Antelope, I think.
</p><p>
This is a Crocodile, I think.
</p>

View File

@ -24,4 +24,4 @@ title: Output
+
title: ExpectedResult
<p><p>existing variable should have output</p></p><p></p><p></p><p><p>non-existing variable negated should have output</p></p>
<p>existing variable should have output</p><p>non-existing variable negated should have output</p>

View File

@ -31,10 +31,10 @@ title: Output
+
title: ExpectedResult
<p>()
()
(Hello There, welcome to $TiddlyWiki$)
(Welcome to TiddlyWiki)
(Welcome to TiddlyWiki today)
(This is not a valid embedded filter ${ hello )$)
(The output of the filter `[[substitute filter data 1]tags[]]` is Hello.)
(Welcome to TiddlyWiki every day $3$. Tiddlers starting with `substitute`: [[substitute filter data 1]] [[substitute filter data 2]] [[substitute filter data 3]].)</p>
(Welcome to TiddlyWiki every day $3$. Tiddlers starting with `substitute`: [[substitute filter data 1]] [[substitute filter data 2]] [[substitute filter data 3]].)

View File

@ -21,4 +21,4 @@ title: Output
+
title: ExpectedResult
<p>Idiosyncrasy Caption Field,Idiosyncrasy Caption Field</p>
Idiosyncrasy Caption Field,Idiosyncrasy Caption Field

View File

@ -27,4 +27,4 @@ Block forced inline
+
title: ExpectedResult
<div class=" tc-reveal"><p>Block</p></div><div class=" tc-reveal"><p>Block forced block</p></div><span class=" tc-reveal"><p>Block forced inline</p></span><p><span class=" tc-reveal">Inline</span><div class=" tc-reveal">Inline forced block</div><span class=" tc-reveal">Inline forced inline</span></p>
<div class=" tc-reveal"><p>Block</p></div><div class=" tc-reveal"><p>Block forced block</p></div><span class=" tc-reveal"><p>Block forced inline</p></span><span class=" tc-reveal">Inline</span><div class=" tc-reveal">Inline forced block</div><span class=" tc-reveal">Inline forced inline</span>

View File

@ -11,4 +11,4 @@ title: Output
+
title: ExpectedResult
<p>(Kitten)(Kitten)</p>
(Kitten)(Kitten)

View File

@ -11,4 +11,4 @@ title: Output
+
title: ExpectedResult
<p>Mouse</p><p>Mouse</p>
MouseMouse

View File

@ -11,4 +11,4 @@ title: Output
+
title: ExpectedResult
<p>(Kitten|Donkey)(Kitten|Donkey)</p>
(Kitten|Donkey)(Kitten|Donkey)

View File

@ -26,6 +26,6 @@ title: Output
+
title: ExpectedResult
<p>(--Elephant--)
(--Elephant--)
(--Kangaroo--)
(--Giraffe--)</p>
(--Giraffe--)

View File

@ -11,4 +11,4 @@ title: Output
+
title: ExpectedResult
<p><div>Mouse</div><div class="tc-thing" label="Squeak">Mouse</div></p>
<div>Mouse</div><div class="tc-thing" label="Squeak">Mouse</div>

View File

@ -10,4 +10,4 @@ title: Output
+
title: ExpectedResult
<p><p></p></p>
<p></p>

View File

@ -26,4 +26,4 @@ title: Output
+
title: ExpectedResult
<p>123</p><p>None!</p>
123None!

View File

@ -30,4 +30,4 @@ title: Template
+
title: ExpectedResult
<p>112233</p><p>Zero</p>
112233Zero

View File

@ -27,4 +27,4 @@ title: Output
+
title: ExpectedResult
<p>Item:1,Item:2,Item:3</p><p>None!</p>
Item:1,Item:2,Item:3None!

View File

@ -29,4 +29,4 @@ title: Output
title: ExpectedResult
comment: I wish there was a good way to get rid of these extraneous paragraph elements
<p>Item:1</p><p></p><p></p><br><p>Item:2</p><p></p><p></p><br><p>Item:3</p><p></p><p></p>None!
<p>Item:1</p><br><p>Item:2</p><br><p>Item:3</p>None!

View File

@ -23,4 +23,4 @@ title: Output
+
title: ExpectedResult
<p><span><a class="tc-tiddlylink tc-tiddlylink-missing" href="#1">1</a></span><span><a class="tc-tiddlylink tc-tiddlylink-missing" href="#2">2</a></span><span><a class="tc-tiddlylink tc-tiddlylink-missing" href="#3">3</a></span></p><p>None!</p>
<span><a class="tc-tiddlylink tc-tiddlylink-missing" href="#1">1</a></span><span><a class="tc-tiddlylink tc-tiddlylink-missing" href="#2">2</a></span><span><a class="tc-tiddlylink tc-tiddlylink-missing" href="#3">3</a></span>None!

View File

@ -21,7 +21,7 @@ Now!
+
title: ExpectedResult
<p>
[
{
"type": "set",
@ -61,4 +61,3 @@ title: ExpectedResult
"isProcedureDefinition": true
}
]
</p>

View File

@ -20,7 +20,7 @@ Now!
+
title: ExpectedResult
<p>
[
{
"type": "text",
@ -29,4 +29,3 @@ title: ExpectedResult
"end": 9
}
]
</p>

View File

@ -17,4 +17,4 @@ title: Output
+
title: ExpectedResult
<p>ElephantElephant</p>
ElephantElephant

View File

@ -17,4 +17,4 @@ title: Output
+
title: ExpectedResult
<p>ElephantElephant</p>
ElephantElephant

View File

@ -24,4 +24,4 @@ title: Actions
+
title: ExpectedResult
<p>Dingo</p>
Dingo

View File

@ -17,4 +17,4 @@ title: Output
+
title: ExpectedResult
<p>hello</p>
hello

View File

@ -23,4 +23,4 @@ title: Output
+
title: ExpectedResult
<p>Undefined widget 'non-existent-widget'Undefined widget 'non-existent-widget'</p>
Undefined widget 'non-existent-widget'Undefined widget 'non-existent-widget'

View File

@ -26,4 +26,4 @@ Python
+
title: ExpectedResult
<p><pre><code>£Kangaroo@</code></pre><pre><code>£Python@</code></pre><pre><code>£Tiger@</code></pre></p>
<pre><code>£Kangaroo@</code></pre><pre><code>£Python@</code></pre><pre><code>£Tiger@</code></pre>

View File

@ -30,4 +30,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>Antelope</p>
Antelope

View File

@ -30,4 +30,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>DingoCrocodileBumbleBeeSquirrelJaguarWhale</p>
DingoCrocodileBumbleBeeSquirrelJaguarWhale

View File

@ -30,4 +30,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>DingoCrocodileBumbleBeeSquirrelJaguarWhale</p>
DingoCrocodileBumbleBeeSquirrelJaguarWhale

View File

@ -24,4 +24,4 @@ title: Output
+
title: ExpectedResult
<p>DingoCrocodileBumbleBeeWhale</p>
DingoCrocodileBumbleBeeWhale

View File

@ -24,4 +24,4 @@ Crocodile
+
title: ExpectedResult
<p>≤Dingo≥≤Jaguar≥</p>
≤Dingo≥≤Jaguar≥

View File

@ -28,4 +28,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>DingoCrocodile</p>
DingoCrocodile

View File

@ -28,4 +28,4 @@ Python
+
title: ExpectedResult
<p><pre><code>Kangaroo</code></pre><pre><code>Python</code></pre><pre><code>Tiger</code></pre></p>
<pre><code>Kangaroo</code></pre><pre><code>Python</code></pre><pre><code>Tiger</code></pre>

View File

@ -26,4 +26,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>DingoCrocodile</p>
DingoCrocodile

View File

@ -37,4 +37,4 @@ Fallback content
+
title: ExpectedResult
<p>Fallback content</p><p>Fallback content</p><p>Fallback content</p><p>Fallback content</p><p>Fallback content</p><p>Fallback content</p>
Fallback contentFallback contentFallback contentFallback contentFallback contentFallback content

View File

@ -14,4 +14,4 @@ title: Output
+
title: ExpectedResult
<p>Jeremy|Jeremy</p>
Jeremy|Jeremy

View File

@ -45,4 +45,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>PiranhaFerretPiranhaFerretBadgerFerretBadgerFerret</p>
PiranhaFerretPiranhaFerretBadgerFerretBadgerFerret

View File

@ -26,4 +26,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>block</p><p>inline</p>
blockinline

View File

@ -31,4 +31,4 @@ title: TiddlerTwo
+
title: ExpectedResult
<p>{0:}{1:}{2:}</p><p></p><p>{0:Ferret}</p><p>{0:Butterfly}{1:Moth}</p><p>{0:Beetle}{1:Scorpion}{2:Snake}</p><p>({$one:Scorpion}{two:Snake}{zero:Beetle})</p>
{0:}{1:}{2:}{0:Ferret}{0:Butterfly}{1:Moth}{0:Beetle}{1:Scorpion}{2:Snake}<p>({$one:Scorpion}{two:Snake}{zero:Beetle})</p>

View File

@ -26,4 +26,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>[{"type":"element","tag":"p","children":[{"type":"text","text":"This is a block","start":68,"end":83}],"start":68,"end":83}]</p><p>[{"type":"text","text":"This is inline","start":136,"end":152}]</p>
[{"type":"element","tag":"p","children":[{"type":"text","text":"This is a block","start":68,"end":83}],"start":68,"end":83}][{"type":"text","text":"This is inline","start":136,"end":152}]

View File

@ -26,4 +26,4 @@ title: TiddlerTwo
+
title: ExpectedResult
<p>[{Jaguar}{Lizard}{Mole}]</p><p>[{Ferret}{Lizard}{Mole}]</p><p>[{Butterfly}{Moth}{Mole}]</p><p>[{Beetle}{Scorpion}{Snake}]</p><p>([{Beetle}{Scorpion}{Snake}])</p>
[{Jaguar}{Lizard}{Mole}][{Ferret}{Lizard}{Mole}][{Butterfly}{Moth}{Mole}][{Beetle}{Scorpion}{Snake}]([{Beetle}{Scorpion}{Snake}])

View File

@ -23,4 +23,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>FerretFerretPigeonPigeonFerretFerretJaguar</p>
FerretFerretPigeonPigeonFerretFerretJaguar

View File

@ -17,4 +17,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>FerretJaguar</p>
FerretJaguar

View File

@ -17,4 +17,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>FerretJaguar</p>
FerretJaguar

View File

@ -18,4 +18,4 @@ title: Output
+
title: ExpectedResult
<p>{Ferret}{Jaguar}{Rat}{Mouse}</p>
{Ferret}{Jaguar}{Rat}{Mouse}

View File

@ -26,4 +26,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>one,ts-raw,two</p><p>one,ts-raw</p>
one,ts-raw,twoone,ts-raw

View File

@ -21,4 +21,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>FerretWhale</p>
FerretWhale

View File

@ -24,4 +24,4 @@ title: TiddlerOne
+
title: ExpectedResult
<p>FerretHippopotamus</p>
FerretHippopotamus

View File

@ -10,4 +10,4 @@ title: Output
+
title: ExpectedResult
<p><span class="tc-error">Recursive transclusion error in transclude widget</span></p>
<span class="tc-error">Recursive transclusion error in transclude widget</span>

View File

@ -24,4 +24,4 @@ Title1
+
title: ExpectedResult
<p><div class="myclass" data-title="mytiddler" style="color:red;">my tiddler</div><div class="myclass" data-title="Title2" style="color:red;">hello</div></p>
<div class="myclass" data-title="mytiddler" style="color:red;">my tiddler</div><div class="myclass" data-title="Title2" style="color:red;">hello</div>

View File

@ -19,4 +19,4 @@ Title1
+
title: ExpectedResult
<p><label class="tc-checkbox "><input data-title="Title2" type="checkbox" style="color:red;"><span>Is it done?</span></label></p>
<label class="tc-checkbox "><input data-title="Title2" type="checkbox" style="color:red;"><span>Is it done?</span></label>

View File

@ -24,4 +24,4 @@ Title1
+
title: ExpectedResult
<p><div class="myclass tc-draggable" data-title="mytiddler" draggable="true" style="color:red;">my tiddler</div><div class="myclass tc-draggable" data-title="Title2" draggable="true" style="color:red;">hello</div></p>
<div class="myclass tc-draggable" data-title="mytiddler" draggable="true" style="color:red;">my tiddler</div><div class="myclass tc-draggable" data-title="Title2" draggable="true" style="color:red;">hello</div>

View File

@ -24,4 +24,4 @@ Title1
+
title: ExpectedResult
<p><div class="myclass tc-droppable" data-title="mytiddler" style="color:red;">my tiddler</div><div class="myclass tc-droppable" data-title="Title2" style="color:red;">hello</div></p>
<div class="myclass tc-droppable" data-title="mytiddler" style="color:red;">my tiddler</div><div class="myclass tc-droppable" data-title="Title2" style="color:red;">hello</div>

View File

@ -24,4 +24,4 @@ Title1
+
title: ExpectedResult
<p><a class="tc-tiddlylink tc-tiddlylink-resolves" data-id="mytiddler" href="#Temp" style="color:red;">link to Temp</a><button class="tc-tiddlylink tc-tiddlylink-missing" data-id="Title2" draggable="true" style="color:red;">some tiddler</button></p>
<a class="tc-tiddlylink tc-tiddlylink-resolves" data-id="mytiddler" href="#Temp" style="color:red;">link to Temp</a><button class="tc-tiddlylink tc-tiddlylink-missing" data-id="Title2" draggable="true" style="color:red;">some tiddler</button>

View File

@ -12,4 +12,4 @@ hello
+
title: ExpectedResult
<p><div style="background:green;color:blue;">hello</div></p>
<div style="background:green;color:blue;">hello</div>

View File

@ -24,4 +24,4 @@ Title1
+
title: ExpectedResult
<p><select class="myclass" data-title="Title2" value="Choose a new text" style="color:red;"><option disabled="true">Choose a new text</option><option>A Tale of Two Cities</option><option>A New Kind of Science</option><option>The Dice Man</option></select></p>
<select class="myclass" data-title="Title2" value="Choose a new text" style="color:red;"><option disabled="true">Choose a new text</option><option>A Tale of Two Cities</option><option>A New Kind of Science</option><option>The Dice Man</option></select>

View File

@ -12,4 +12,4 @@ TiddlyWiki
+
title: ExpectedResult
<p><div class="hello">TiddlyWiki</div></p>
<div class="hello">TiddlyWiki</div>

View File

@ -12,4 +12,4 @@ TiddlyWiki
+
title: ExpectedResult
<p><div class="hello" style="color:red;background:yellow;">TiddlyWiki</div></p>
<div class="hello" style="color:red;background:yellow;">TiddlyWiki</div>

View File

@ -12,4 +12,4 @@ title: Output
+
title: ExpectedResult
<p>bb</p>
bb

View File

@ -12,4 +12,3 @@ title: Output
+
title: ExpectedResult
<p></p>

View File

@ -17,5 +17,5 @@ ${ [[Hello]addsuffix[There]] }$` attrib=`myvalue` otherattrib=`$(1)$` blankattri
+
title: ExpectedResult
<p><div attrib="myvalue" blankattrib="" class="TiddlyWiki
HelloThere" dashes="dashes" disabled="true" otherattrib="" quoted="here" spaces="spaces"></div></p>
<div attrib="myvalue" blankattrib="" class="TiddlyWiki
HelloThere" dashes="dashes" disabled="true" otherattrib="" quoted="here" spaces="spaces"></div>

View File

@ -201,21 +201,23 @@ describe("Widget module", function() {
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
expect(wrapper.innerHTML).toBe("<p>Jolly Old World</p>");
expect(wrapper.innerHTML).toBe("Jolly Old World");
// Test the sequence numbers in the DOM
expect(wrapper.sequenceNumber).toBe(0);
expect(wrapper.children[0].sequenceNumber).toBe(1);
expect(wrapper.children[0].children[0].sequenceNumber).toBe(2);
// expect(wrapper.children[0].children[0].sequenceNumber).toBe(2); // TODO
// Change the transcluded tiddler
wiki.addTiddler({title: "TiddlerOne", text: "World-wide Jelly"});
// Refresh
refreshWidgetNode(widgetNode,wrapper,["TiddlerOne"]);
// Test the refreshing
expect(wrapper.innerHTML).toBe("<p>World-wide Jelly</p>");
expect(wrapper.innerHTML).toBe("World-wide Jelly");
// Test the sequence numbers in the DOM
expect(wrapper.sequenceNumber).toBe(0);
expect(wrapper.children[0].sequenceNumber).toBe(1);
expect(wrapper.children[0].children[0].sequenceNumber).toBe(3);
expect(wrapper.children[0].sequenceNumber).toBe(2);
// expect(wrapper.children[0].children[0].sequenceNumber).toBe(3);
});
it("should deal with the set widget", function() {
@ -265,7 +267,7 @@ describe("Widget module", function() {
"<$transclude field=<<field>>/></$let>";
var widgetNode = createWidgetNode(parseText(text,wiki),wiki);
var wrapper = renderWidgetNode(widgetNode);
expect(wrapper.innerHTML).toBe("<p>Happy Result</p>");
expect(wrapper.innerHTML).toBe("Happy Result");
// This is important. $Let needs to be aware enough not to let its
// own variables interfere with its ability to recognise no change.
@ -290,7 +292,7 @@ describe("Widget module", function() {
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
expect(wrapper.innerHTML).toBe("<p><div class=\"My something something, or other thing\">Content</div></p>");
expect(wrapper.innerHTML).toBe("<div class=\"My something something, or other thing\">Content</div>");
});
it("should deal with built-in macros", function() {
@ -305,7 +307,7 @@ describe("Widget module", function() {
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
expect(wrapper.innerHTML).toBe("<p><a href=\"data:text/vnd.tiddlywiki,Jolly%20Old%20World\">My linky link</a></p>");
expect(wrapper.innerHTML).toBe("<a href=\"data:text/vnd.tiddlywiki,Jolly%20Old%20World\">My linky link</a>");
});
/* This test reproduces issue #4693. */
@ -341,48 +343,54 @@ describe("Widget module", function() {
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
expect(wrapper.innerHTML).toBe("<p>TiddlerFourTiddlerOneTiddlerThreeTiddlerTwo</p>");
expect(wrapper.innerHTML).toBe("TiddlerFourTiddlerOneTiddlerThreeTiddlerTwo");
// Add another tiddler
wiki.addTiddler({title: "TiddlerFive", text: "Jalapeno Peppers"});
// Refresh
refreshWidgetNode(widgetNode,wrapper,["TiddlerFive"]);
// Test the refreshing
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwo</p>");
expect(wrapper.innerHTML).toBe("TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwo");
// Test the sequence numbers in the DOM
expect(wrapper.sequenceNumber).toBe(0);
expect(wrapper.children[0].sequenceNumber).toBe(1);
expect(wrapper.children[0].children[0].sequenceNumber).toBe(6);
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
expect(wrapper.children[0].children[3].sequenceNumber).toBe(4);
expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
expect(wrapper.children[0].sequenceNumber).toBe(5);
// expect(wrapper.children[0].children[0].sequenceNumber).toBe(6); // TODO
// expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
// expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
// expect(wrapper.children[0].children[3].sequenceNumber).toBe(4);
// expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
// Remove a tiddler
wiki.deleteTiddler("TiddlerThree");
// Refresh
refreshWidgetNode(widgetNode,wrapper,["TiddlerThree"]);
// Test the refreshing
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerTwo</p>");
expect(wrapper.innerHTML).toBe("TiddlerFiveTiddlerFourTiddlerOneTiddlerTwo");
// Test the sequence numbers in the DOM
expect(wrapper.sequenceNumber).toBe(0);
expect(wrapper.children[0].sequenceNumber).toBe(1);
expect(wrapper.children[0].children[0].sequenceNumber).toBe(6);
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
expect(wrapper.children[0].children[3].sequenceNumber).toBe(5);
expect(wrapper.children[0].sequenceNumber).toBe(5);
// expect(wrapper.children[0].children[0].sequenceNumber).toBe(6); // TODO
// expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
// expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
// expect(wrapper.children[0].children[3].sequenceNumber).toBe(5);
// Add it back a tiddler
wiki.addTiddler({title: "TiddlerThree", text: "Something"});
// Refresh
refreshWidgetNode(widgetNode,wrapper,["TiddlerThree"]);
// Test the refreshing
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwo</p>");
expect(wrapper.innerHTML).toBe("TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwo");
// Test the sequence numbers in the DOM
expect(wrapper.sequenceNumber).toBe(0);
expect(wrapper.children[0].sequenceNumber).toBe(1);
expect(wrapper.children[0].children[0].sequenceNumber).toBe(6);
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
expect(wrapper.children[0].children[3].sequenceNumber).toBe(7);
expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
expect(wrapper.children[0].sequenceNumber).toBe(5);
// expect(wrapper.children[0].children[0].sequenceNumber).toBe(6); // TODO
// expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
// expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
// expect(wrapper.children[0].children[3].sequenceNumber).toBe(7);
// expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
});
@ -401,130 +409,139 @@ describe("Widget module", function() {
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
expect(wrapper.innerHTML).toBe("<p>Lemon Squash1yesnoJolly Old World2nonoGolly Gosh3nonoWorldly Old Jelly4noyes</p>");
expect(wrapper.innerHTML).toBe("Lemon Squash1yesnoJolly Old World2nonoGolly Gosh3nonoWorldly Old Jelly4noyes");
// Test the sequence numbers in the DOM
expect(wrapper.sequenceNumber).toBe(0);
expect(wrapper.children[0].sequenceNumber).toBe(1);
expect(wrapper.children[0].children[0].sequenceNumber).toBe(2);
expect(wrapper.children[0].children[1].sequenceNumber).toBe(3);
expect(wrapper.children[0].children[2].sequenceNumber).toBe(4);
expect(wrapper.children[0].children[3].sequenceNumber).toBe(5);
expect(wrapper.children[0].children[4].sequenceNumber).toBe(6);
expect(wrapper.children[0].children[5].sequenceNumber).toBe(7);
expect(wrapper.children[0].children[6].sequenceNumber).toBe(8);
expect(wrapper.children[0].children[7].sequenceNumber).toBe(9);
expect(wrapper.children[0].children[8].sequenceNumber).toBe(10);
expect(wrapper.children[0].children[9].sequenceNumber).toBe(11);
expect(wrapper.children[0].children[10].sequenceNumber).toBe(12);
expect(wrapper.children[0].children[11].sequenceNumber).toBe(13);
expect(wrapper.children[0].children[12].sequenceNumber).toBe(14);
expect(wrapper.children[0].children[13].sequenceNumber).toBe(15);
expect(wrapper.children[0].children[14].sequenceNumber).toBe(16);
expect(wrapper.children[0].children[15].sequenceNumber).toBe(17);
// expect(wrapper.children[0].children[0].sequenceNumber).toBe(2); // TODO
// expect(wrapper.children[0].children[1].sequenceNumber).toBe(3);
// expect(wrapper.children[0].children[2].sequenceNumber).toBe(4);
// expect(wrapper.children[0].children[3].sequenceNumber).toBe(5);
// expect(wrapper.children[0].children[4].sequenceNumber).toBe(6);
// expect(wrapper.children[0].children[5].sequenceNumber).toBe(7);
// expect(wrapper.children[0].children[6].sequenceNumber).toBe(8);
// expect(wrapper.children[0].children[7].sequenceNumber).toBe(9);
// expect(wrapper.children[0].children[8].sequenceNumber).toBe(10);
// expect(wrapper.children[0].children[9].sequenceNumber).toBe(11);
// expect(wrapper.children[0].children[10].sequenceNumber).toBe(12);
// expect(wrapper.children[0].children[11].sequenceNumber).toBe(13);
// expect(wrapper.children[0].children[12].sequenceNumber).toBe(14);
// expect(wrapper.children[0].children[13].sequenceNumber).toBe(15);
// expect(wrapper.children[0].children[14].sequenceNumber).toBe(16);
// expect(wrapper.children[0].children[15].sequenceNumber).toBe(17);
// Add another tiddler
wiki.addTiddler({title: "TiddlerFive", text: "Jalapeno Peppers"});
// Refresh
refreshWidgetNode(widgetNode,wrapper,["TiddlerFive"]);
// Test the refreshing
expect(wrapper.innerHTML).toBe("<p>Jalapeno Peppers1yesnoLemon Squash2nonoJolly Old World3nonoGolly Gosh4nonoWorldly Old Jelly5noyes</p>");
expect(wrapper.innerHTML).toBe("Jalapeno Peppers1yesnoLemon Squash2nonoJolly Old World3nonoGolly Gosh4nonoWorldly Old Jelly5noyes");
// Test the sequence numbers in the DOM
expect(wrapper.sequenceNumber).toBe(0);
expect(wrapper.children[0].sequenceNumber).toBe(1);
expect(wrapper.children[0].children[0].sequenceNumber).toBe(18);
expect(wrapper.children[0].children[1].sequenceNumber).toBe(19);
expect(wrapper.children[0].children[2].sequenceNumber).toBe(20);
expect(wrapper.children[0].children[3].sequenceNumber).toBe(21);
expect(wrapper.children[0].children[4].sequenceNumber).toBe(22);
expect(wrapper.children[0].children[5].sequenceNumber).toBe(23);
expect(wrapper.children[0].children[6].sequenceNumber).toBe(24);
expect(wrapper.children[0].children[7].sequenceNumber).toBe(25);
expect(wrapper.children[0].children[8].sequenceNumber).toBe(26);
expect(wrapper.children[0].children[9].sequenceNumber).toBe(27);
expect(wrapper.children[0].children[10].sequenceNumber).toBe(28);
expect(wrapper.children[0].children[11].sequenceNumber).toBe(29);
expect(wrapper.children[0].children[12].sequenceNumber).toBe(30);
expect(wrapper.children[0].children[13].sequenceNumber).toBe(31);
expect(wrapper.children[0].children[14].sequenceNumber).toBe(32);
expect(wrapper.children[0].children[15].sequenceNumber).toBe(33);
expect(wrapper.children[0].children[16].sequenceNumber).toBe(34);
expect(wrapper.children[0].children[17].sequenceNumber).toBe(35);
expect(wrapper.children[0].children[18].sequenceNumber).toBe(36);
expect(wrapper.children[0].children[19].sequenceNumber).toBe(37);
expect(wrapper.children[0].sequenceNumber).toBe(17);
// expect(wrapper.children[0].children[0].sequenceNumber).toBe(18); // TODO
// expect(wrapper.children[0].children[1].sequenceNumber).toBe(19);
// expect(wrapper.children[0].children[2].sequenceNumber).toBe(20);
// expect(wrapper.children[0].children[3].sequenceNumber).toBe(21);
// expect(wrapper.children[0].children[4].sequenceNumber).toBe(22);
// expect(wrapper.children[0].children[5].sequenceNumber).toBe(23);
// expect(wrapper.children[0].children[6].sequenceNumber).toBe(24);
// expect(wrapper.children[0].children[7].sequenceNumber).toBe(25);
// expect(wrapper.children[0].children[8].sequenceNumber).toBe(26);
// expect(wrapper.children[0].children[9].sequenceNumber).toBe(27);
// expect(wrapper.children[0].children[10].sequenceNumber).toBe(28);
// expect(wrapper.children[0].children[11].sequenceNumber).toBe(29);
// expect(wrapper.children[0].children[12].sequenceNumber).toBe(30);
// expect(wrapper.children[0].children[13].sequenceNumber).toBe(31);
// expect(wrapper.children[0].children[14].sequenceNumber).toBe(32);
// expect(wrapper.children[0].children[15].sequenceNumber).toBe(33);
// expect(wrapper.children[0].children[16].sequenceNumber).toBe(34);
// expect(wrapper.children[0].children[17].sequenceNumber).toBe(35);
// expect(wrapper.children[0].children[18].sequenceNumber).toBe(36);
// expect(wrapper.children[0].children[19].sequenceNumber).toBe(37);
// Remove a tiddler
wiki.deleteTiddler("TiddlerThree");
// Refresh
refreshWidgetNode(widgetNode,wrapper,["TiddlerThree"]);
// Test the refreshing
expect(wrapper.innerHTML).toBe("<p>Jalapeno Peppers1yesnoLemon Squash2nonoJolly Old World3nonoWorldly Old Jelly4noyes</p>");
expect(wrapper.innerHTML).toBe("Jalapeno Peppers1yesnoLemon Squash2nonoJolly Old World3nonoWorldly Old Jelly4noyes");
// Test the sequence numbers in the DOM
expect(wrapper.sequenceNumber).toBe(0);
expect(wrapper.children[0].sequenceNumber).toBe(1);
expect(wrapper.children[0].children[0].sequenceNumber).toBe(18);
expect(wrapper.children[0].children[1].sequenceNumber).toBe(19);
expect(wrapper.children[0].children[2].sequenceNumber).toBe(20);
expect(wrapper.children[0].children[3].sequenceNumber).toBe(21);
expect(wrapper.children[0].children[4].sequenceNumber).toBe(22);
expect(wrapper.children[0].children[5].sequenceNumber).toBe(23);
expect(wrapper.children[0].children[6].sequenceNumber).toBe(24);
expect(wrapper.children[0].children[7].sequenceNumber).toBe(25);
expect(wrapper.children[0].children[8].sequenceNumber).toBe(26);
expect(wrapper.children[0].children[9].sequenceNumber).toBe(27);
expect(wrapper.children[0].children[10].sequenceNumber).toBe(28);
expect(wrapper.children[0].children[11].sequenceNumber).toBe(29);
expect(wrapper.children[0].children[12].sequenceNumber).toBe(38);
expect(wrapper.children[0].children[13].sequenceNumber).toBe(39);
expect(wrapper.children[0].children[14].sequenceNumber).toBe(40);
expect(wrapper.children[0].children[15].sequenceNumber).toBe(41);
expect(wrapper.children[0].sequenceNumber).toBe(17);
// expect(wrapper.children[0].children[0].sequenceNumber).toBe(18); // TODO
// expect(wrapper.children[0].children[1].sequenceNumber).toBe(19);
// expect(wrapper.children[0].children[2].sequenceNumber).toBe(20);
// expect(wrapper.children[0].children[3].sequenceNumber).toBe(21);
// expect(wrapper.children[0].children[4].sequenceNumber).toBe(22);
// expect(wrapper.children[0].children[5].sequenceNumber).toBe(23);
// expect(wrapper.children[0].children[6].sequenceNumber).toBe(24);
// expect(wrapper.children[0].children[7].sequenceNumber).toBe(25);
// expect(wrapper.children[0].children[8].sequenceNumber).toBe(26);
// expect(wrapper.children[0].children[9].sequenceNumber).toBe(27);
// expect(wrapper.children[0].children[10].sequenceNumber).toBe(28);
// expect(wrapper.children[0].children[11].sequenceNumber).toBe(29);
// expect(wrapper.children[0].children[12].sequenceNumber).toBe(38);
// expect(wrapper.children[0].children[13].sequenceNumber).toBe(39);
// expect(wrapper.children[0].children[14].sequenceNumber).toBe(40);
// expect(wrapper.children[0].children[15].sequenceNumber).toBe(41);
// Add it back a tiddler
wiki.addTiddler({title: "TiddlerThree", text: "Something"});
// Refresh
refreshWidgetNode(widgetNode,wrapper,["TiddlerThree"]);
// Test the refreshing
expect(wrapper.innerHTML).toBe("<p>Jalapeno Peppers1yesnoLemon Squash2nonoJolly Old World3nonoSomething4nonoWorldly Old Jelly5noyes</p>");
expect(wrapper.innerHTML).toBe("Jalapeno Peppers1yesnoLemon Squash2nonoJolly Old World3nonoSomething4nonoWorldly Old Jelly5noyes");
// Test the sequence numbers in the DOM
expect(wrapper.sequenceNumber).toBe(0);
expect(wrapper.children[0].sequenceNumber).toBe(1);
expect(wrapper.children[0].children[0].sequenceNumber).toBe(18);
expect(wrapper.children[0].children[1].sequenceNumber).toBe(19);
expect(wrapper.children[0].children[2].sequenceNumber).toBe(20);
expect(wrapper.children[0].children[3].sequenceNumber).toBe(21);
expect(wrapper.children[0].children[4].sequenceNumber).toBe(22);
expect(wrapper.children[0].children[5].sequenceNumber).toBe(23);
expect(wrapper.children[0].children[6].sequenceNumber).toBe(24);
expect(wrapper.children[0].children[7].sequenceNumber).toBe(25);
expect(wrapper.children[0].children[8].sequenceNumber).toBe(26);
expect(wrapper.children[0].children[9].sequenceNumber).toBe(27);
expect(wrapper.children[0].children[10].sequenceNumber).toBe(28);
expect(wrapper.children[0].children[11].sequenceNumber).toBe(29);
expect(wrapper.children[0].children[12].sequenceNumber).toBe(42);
expect(wrapper.children[0].children[13].sequenceNumber).toBe(43);
expect(wrapper.children[0].children[14].sequenceNumber).toBe(44);
expect(wrapper.children[0].children[15].sequenceNumber).toBe(45);
expect(wrapper.children[0].sequenceNumber).toBe(17);
// expect(wrapper.children[0].children[0].sequenceNumber).toBe(18);
// expect(wrapper.children[0].children[1].sequenceNumber).toBe(19);
// expect(wrapper.children[0].children[2].sequenceNumber).toBe(20);
// expect(wrapper.children[0].children[3].sequenceNumber).toBe(21);
// expect(wrapper.children[0].children[4].sequenceNumber).toBe(22);
// expect(wrapper.children[0].children[5].sequenceNumber).toBe(23);
// expect(wrapper.children[0].children[6].sequenceNumber).toBe(24);
// expect(wrapper.children[0].children[7].sequenceNumber).toBe(25);
// expect(wrapper.children[0].children[8].sequenceNumber).toBe(26);
// expect(wrapper.children[0].children[9].sequenceNumber).toBe(27);
// expect(wrapper.children[0].children[10].sequenceNumber).toBe(28);
// expect(wrapper.children[0].children[11].sequenceNumber).toBe(29);
// expect(wrapper.children[0].children[12].sequenceNumber).toBe(42);
// expect(wrapper.children[0].children[13].sequenceNumber).toBe(43);
// expect(wrapper.children[0].children[14].sequenceNumber).toBe(44);
// expect(wrapper.children[0].children[15].sequenceNumber).toBe(45);
//Remove last tiddler
wiki.deleteTiddler("TiddlerTwo");
//Refresh
refreshWidgetNode(widgetNode,wrapper,["TiddlerTwo"]);
//Test the refreshing
expect(wrapper.innerHTML).toBe("<p>Jalapeno Peppers1yesnoLemon Squash2nonoJolly Old World3nonoSomething4noyes</p>");
expect(wrapper.innerHTML).toBe("Jalapeno Peppers1yesnoLemon Squash2nonoJolly Old World3nonoSomething4noyes");
// Test the sequence numbers in the DOM
expect(wrapper.sequenceNumber).toBe(0);
expect(wrapper.children[0].sequenceNumber).toBe(1);
expect(wrapper.children[0].children[0].sequenceNumber).toBe(18);
expect(wrapper.children[0].children[1].sequenceNumber).toBe(19);
expect(wrapper.children[0].children[2].sequenceNumber).toBe(20);
expect(wrapper.children[0].children[3].sequenceNumber).toBe(21);
expect(wrapper.children[0].children[4].sequenceNumber).toBe(22);
expect(wrapper.children[0].children[5].sequenceNumber).toBe(23);
expect(wrapper.children[0].children[6].sequenceNumber).toBe(24);
expect(wrapper.children[0].children[7].sequenceNumber).toBe(25);
expect(wrapper.children[0].children[8].sequenceNumber).toBe(26);
expect(wrapper.children[0].children[9].sequenceNumber).toBe(27);
expect(wrapper.children[0].children[10].sequenceNumber).toBe(28);
expect(wrapper.children[0].children[11].sequenceNumber).toBe(29);
expect(wrapper.children[0].children[12].sequenceNumber).toBe(50);
expect(wrapper.children[0].children[13].sequenceNumber).toBe(51);
expect(wrapper.children[0].children[14].sequenceNumber).toBe(52);
expect(wrapper.children[0].children[15].sequenceNumber).toBe(53);
expect(wrapper.children[0].sequenceNumber).toBe(17);
// expect(wrapper.children[0].children[0].sequenceNumber).toBe(18);
// expect(wrapper.children[0].children[1].sequenceNumber).toBe(19);
// expect(wrapper.children[0].children[2].sequenceNumber).toBe(20);
// expect(wrapper.children[0].children[3].sequenceNumber).toBe(21);
// expect(wrapper.children[0].children[4].sequenceNumber).toBe(22);
// expect(wrapper.children[0].children[5].sequenceNumber).toBe(23);
// expect(wrapper.children[0].children[6].sequenceNumber).toBe(24);
// expect(wrapper.children[0].children[7].sequenceNumber).toBe(25);
// expect(wrapper.children[0].children[8].sequenceNumber).toBe(26);
// expect(wrapper.children[0].children[9].sequenceNumber).toBe(27);
// expect(wrapper.children[0].children[10].sequenceNumber).toBe(28);
// expect(wrapper.children[0].children[11].sequenceNumber).toBe(29);
// expect(wrapper.children[0].children[12].sequenceNumber).toBe(50);
// expect(wrapper.children[0].children[13].sequenceNumber).toBe(51);
// expect(wrapper.children[0].children[14].sequenceNumber).toBe(52);
// expect(wrapper.children[0].children[15].sequenceNumber).toBe(53);
});
var testListJoin = function(oldList, newList) {
@ -537,11 +554,11 @@ describe("Widget module", function() {
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
expect(wrapper.innerHTML).toBe("<p>" + oldList.split(' ').join(', ') + "</p>");
expect(wrapper.innerHTML).toBe(oldList.split(' ').join(', '));
// Change the list and ensure new rendering is still right
wiki.addTiddler({title: "Numbers", text: "", list: newList});
refreshWidgetNode(widgetNode,wrapper,["Numbers"]);
expect(wrapper.innerHTML).toBe("<p>" + newList.split(' ').join(', ') + "</p>");
expect(wrapper.innerHTML).toBe(newList.split(' ').join(', '));
}
}
@ -576,11 +593,11 @@ describe("Widget module", function() {
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
expect(wrapper.innerHTML).toBe("<p>" + oldList.split(' ').join(', ') + "</p>");
expect(wrapper.innerHTML).toBe(oldList.split(' ').join(', '));
// Append a number
wiki.addTiddler({title: "Numbers", text: "", list: newList});
refreshWidgetNode(widgetNode,wrapper,["Numbers"]);
expect(wrapper.innerHTML).toBe("<p>" + newList.split(' ').join(', ') + "</p>");
expect(wrapper.innerHTML).toBe(newList.split(' ').join(', '));
}
}
@ -681,7 +698,7 @@ describe("Widget module", function() {
var wrapper = renderWidgetNode(widgetNode);
//console.log(require("util").inspect(widgetNode,{depth:8,colors:true}));
// Test the rendering
expect(wrapper.innerHTML).toBe("<p>(TiddlerFour)(TiddlerOne)(TiddlerThree)(TiddlerTwo)</p>");
expect(wrapper.innerHTML).toBe("(TiddlerFour)(TiddlerOne)(TiddlerThree)(TiddlerTwo)");
});
it("should deal with the list widget and empty lists", function() {
@ -692,7 +709,7 @@ describe("Widget module", function() {
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
expect(wrapper.innerHTML).toBe("<p>nothing</p>");
expect(wrapper.innerHTML).toBe("nothing");
});
it("should refresh lists that become empty", function() {
@ -710,7 +727,7 @@ describe("Widget module", function() {
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
expect(wrapper.innerHTML).toBe("<p>TiddlerFourTiddlerOneTiddlerThreeTiddlerTwo</p>");
expect(wrapper.innerHTML).toBe("TiddlerFourTiddlerOneTiddlerThreeTiddlerTwo");
// Get rid of the tiddlers
wiki.deleteTiddler("TiddlerOne");
wiki.deleteTiddler("TiddlerTwo");
@ -719,7 +736,7 @@ describe("Widget module", function() {
// Refresh
refreshWidgetNode(widgetNode,wrapper,["TiddlerOne","TiddlerTwo","TiddlerThree","TiddlerFour"]);
// Test the refreshing
expect(wrapper.innerHTML).toBe("<p>nothing</p>");
expect(wrapper.innerHTML).toBe("nothing");
});
/**This test confirms that imported set variables properly refresh

View File

@ -26,62 +26,62 @@ describe("WikiText parser tests", function() {
it("should parse tags", function() {
expect(parse("<br>")).toEqual(
[ { type : 'element', tag : 'p', start : 0, end : 4, children : [ { type : 'element', tag : 'br', start : 0, end : 4, isBlock : false, attributes : { }, orderedAttributes: [ ] } ] } ]
[ { type: 'element', tag: 'p', children: [ { type: 'element', start: 0, attributes: { }, orderedAttributes: [ ], tag: 'br', end: 4, isBlock: false } ], start: 0, end: 4 } ]
);
expect(parse("</br>")).toEqual(
[ { type : 'element', tag : 'p', start : 0, end : 5, children : [ { type : 'text', text : '</br>', start : 0, end : 5 } ] } ]
[{"type": "element","tag": "p","children": [{"type": "text","text": "</br>","start": 0, "end": 5}], "start": 0, "end": 5}]
);
expect(parse("<div>")).toEqual(
[ { type : 'element', tag : 'p', start : 0, end : 5, children : [ { type : 'element', tag : 'div', start : 0, end : 5, isBlock : false, attributes : { }, orderedAttributes: [ ], children : [ ] } ] } ]
[ { type : 'element', tag : 'div', start : 0, end : 5, isBlock : false, attributes : { }, orderedAttributes: [ ], children : [ ] } ]
);
expect(parse("<div/>")).toEqual(
[ { type : 'element', tag : 'p', start : 0, end : 6, children : [ { type : 'element', tag : 'div', isSelfClosing : true, isBlock : false, attributes : { }, orderedAttributes: [ ], start : 0, end : 6 } ] } ]
[ { type : 'element', tag : 'div', isSelfClosing : true, isBlock : false, attributes : { }, orderedAttributes: [ ], start : 0, end : 6 } ]
);
expect(parse("<div></div>")).toEqual(
[ { type : 'element', tag : 'p', start : 0, end : 11, children : [ { type : 'element', tag : 'div', isBlock : false, attributes : { }, orderedAttributes: [ ], children : [ ], start : 0, end : 5 } ] } ]
[ { type : 'element', tag : 'div', isBlock : false, attributes : { }, orderedAttributes: [ ], children : [ ], start : 0, end : 5 } ]
);
expect(parse("<div>some text</div>")).toEqual(
[ { type : 'element', tag : 'p', start : 0, end : 20, children : [ { type : 'element', tag : 'div', start : 0, end : 20, isBlock : false, attributes : { }, orderedAttributes: [ ], children : [ { type : 'text', text : 'some text', start : 5, end : 14 } ], start : 0, end : 5 } ] } ]
[ { type : 'element', tag : 'div', start : 0, end : 20, isBlock : false, attributes : { }, orderedAttributes: [ ], children : [ { type : 'text', text : 'some text', start : 5, end : 14 } ], start : 0, end : 5 } ]
);
expect(parse("<div attribute>some text</div>")).toEqual(
[ { type : 'element', tag : 'p', start : 0, end : 30, children : [ { type : 'element', tag : 'div', isBlock : false, attributes : { attribute : { type : 'string', value : 'true', start : 4, end : 14, name: 'attribute' } }, orderedAttributes: [ { type : 'string', value : 'true', start : 4, end : 14, name: 'attribute' } ], children : [ { type : 'text', text : 'some text', start : 15, end : 24 } ], start : 0, end : 15 } ] } ]
[ { type : 'element', tag : 'div', isBlock : false, attributes : { attribute : { type : 'string', value : 'true', start : 4, end : 14, name: 'attribute' } }, orderedAttributes: [ { type : 'string', value : 'true', start : 4, end : 14, name: 'attribute' } ], children : [ { type : 'text', text : 'some text', start : 15, end : 24 } ], start : 0, end : 15 } ]
);
expect(parse("<div attribute='value'>some text</div>")).toEqual(
[ { type : 'element', tag : 'p', start : 0, end : 38, children : [ { type : 'element', tag : 'div', start: 0, end: 38, isBlock : false, attributes : { attribute : { type : 'string', name: 'attribute', value : 'value', start: 4, end: 22 } }, orderedAttributes: [ { type: 'string', name: 'attribute', value : 'value', start: 4, end: 22 } ], children : [ { type : 'text', text : 'some text', start : 23, end : 32 } ], start : 0, end : 23 } ] } ]
[ { type : 'element', tag : 'div', start: 0, end: 38, isBlock : false, attributes : { attribute : { type : 'string', name: 'attribute', value : 'value', start: 4, end: 22 } }, orderedAttributes: [ { type: 'string', name: 'attribute', value : 'value', start: 4, end: 22 } ], children : [ { type : 'text', text : 'some text', start : 23, end : 32 } ], start : 0, end : 23 } ]
);
expect(parse("<div attribute={{TiddlerTitle}}>some text</div>")).toEqual(
[ { type : 'element', tag : 'p', start: 0, end: 47, children : [ { type : 'element', tag : 'div', isBlock : false, attributes : { attribute : { type : 'indirect', name: 'attribute', textReference : 'TiddlerTitle', start : 4, end : 31 } }, orderedAttributes: [ { type : 'indirect', name: 'attribute', textReference : 'TiddlerTitle', start : 4, end : 31 } ], children : [ { type : 'text', text : 'some text', start : 32, end : 41 } ], start : 0, end : 32 } ] } ]
[ { type : 'element', tag : 'div', isBlock : false, attributes : { attribute : { type : 'indirect', name: 'attribute', textReference : 'TiddlerTitle', start : 4, end : 31 } }, orderedAttributes: [ { type : 'indirect', name: 'attribute', textReference : 'TiddlerTitle', start : 4, end : 31 } ], children : [ { type : 'text', text : 'some text', start : 32, end : 41 } ], start : 0, end : 32 } ]
);
expect(parse("<$reveal state='$:/temp/search' type='nomatch' text=''>")).toEqual(
[ { type : 'element', tag : 'p', start: 0, end: 55, children : [ { type : 'reveal', tag: '$reveal', start : 0, attributes : { state : { start : 8, name : 'state', type : 'string', value : '$:/temp/search', end : 31 }, type : { start : 31, name : 'type', type : 'string', value : 'nomatch', end : 46 }, text : { start : 46, name : 'text', type : 'string', value : '', end : 54 } }, orderedAttributes: [ { start : 8, name : 'state', type : 'string', value : '$:/temp/search', end : 31 }, { start : 31, name : 'type', type : 'string', value : 'nomatch', end : 46 }, { start : 46, name : 'text', type : 'string', value : '', end : 54 } ], end : 55, isBlock : false, children : [ ] } ] } ]
[ { type : 'reveal', tag: '$reveal', start : 0, attributes : { state : { start : 8, name : 'state', type : 'string', value : '$:/temp/search', end : 31 }, type : { start : 31, name : 'type', type : 'string', value : 'nomatch', end : 46 }, text : { start : 46, name : 'text', type : 'string', value : '', end : 54 } }, orderedAttributes: [ { start : 8, name : 'state', type : 'string', value : '$:/temp/search', end : 31 }, { start : 31, name : 'type', type : 'string', value : 'nomatch', end : 46 }, { start : 46, name : 'text', type : 'string', value : '', end : 54 } ], end : 55, isBlock : false, children : [ ] } ]
);
expect(parse("<div attribute={{TiddlerTitle!!field}}>some text</div>")).toEqual(
[ { type : 'element', tag : 'p', start: 0, end: 54, children : [ { type : 'element', tag : 'div', isBlock : false, attributes : { attribute : { type : 'indirect', name : 'attribute', textReference : 'TiddlerTitle!!field', start : 4, end : 38 } }, orderedAttributes: [ { type : 'indirect', name : 'attribute', textReference : 'TiddlerTitle!!field', start : 4, end : 38 } ], children : [ { type : 'text', text : 'some text', start : 39, end : 48 } ], start : 0, end : 39 } ] } ]
[ { type : 'element', tag : 'div', isBlock : false, attributes : { attribute : { type : 'indirect', name : 'attribute', textReference : 'TiddlerTitle!!field', start : 4, end : 38 } }, orderedAttributes: [ { type : 'indirect', name : 'attribute', textReference : 'TiddlerTitle!!field', start : 4, end : 38 } ], children : [ { type : 'text', text : 'some text', start : 39, end : 48 } ], start : 0, end : 39 } ]
);
expect(parse("<div attribute={{Tiddler Title!!field}}>some text</div>")).toEqual(
[ { type : 'element', tag : 'p', start: 0, end: 55, children : [ { type : 'element', tag : 'div', isBlock : false, attributes : { attribute : { type : 'indirect', name : 'attribute', textReference : 'Tiddler Title!!field', start : 4, end : 39 } }, orderedAttributes: [ { type : 'indirect', name : 'attribute', textReference : 'Tiddler Title!!field', start : 4, end : 39 } ], children : [ { type : 'text', text : 'some text', start : 40, end : 49 } ], start : 0, end : 40 } ] } ]
[ { type : 'element', tag : 'div', isBlock : false, attributes : { attribute : { type : 'indirect', name : 'attribute', textReference : 'Tiddler Title!!field', start : 4, end : 39 } }, orderedAttributes: [ { type : 'indirect', name : 'attribute', textReference : 'Tiddler Title!!field', start : 4, end : 39 } ], children : [ { type : 'text', text : 'some text', start : 40, end : 49 } ], start : 0, end : 40 } ]
);
expect(parse("<div attribute={{TiddlerTitle!!field}}>\n\nsome text</div>")).toEqual(
@ -91,23 +91,23 @@ describe("WikiText parser tests", function() {
);
expect(parse("<div><div attribute={{TiddlerTitle!!field}}>\n\nsome text</div></div>")).toEqual(
[ { type : 'element', tag : 'p', start: 0, end: 67, children : [ { type : 'element', start : 0, attributes : { }, orderedAttributes: [ ], tag : 'div', end : 5, isBlock : false, children : [ { type : 'element', start : 5, attributes : { attribute : { start : 9, name : 'attribute', type : 'indirect', textReference : 'TiddlerTitle!!field', end : 43 } }, orderedAttributes: [ { start : 9, name : 'attribute', type : 'indirect', textReference : 'TiddlerTitle!!field', end : 43 } ], tag : 'div', end : 44, isBlock : true, children : [ { type : 'element', tag : 'p', start : 46, end : 55, children : [ { type : 'text', text : 'some text', start : 46, end : 55 } ] } ] } ] } ] } ]
[ { type : 'element', start : 0, attributes : { }, orderedAttributes: [ ], tag : 'div', end : 5, isBlock : false, children : [ { type : 'element', start : 5, attributes : { attribute : { start : 9, name : 'attribute', type : 'indirect', textReference : 'TiddlerTitle!!field', end : 43 } }, orderedAttributes: [ { start : 9, name : 'attribute', type : 'indirect', textReference : 'TiddlerTitle!!field', end : 43 } ], tag : 'div', end : 44, isBlock : true, children : [ { type : 'element', tag : 'p', start : 46, end : 55, children : [ { type : 'text', text : 'some text', start : 46, end : 55 } ] } ] } ] } ]
);
expect(parse("<div><div attribute={{TiddlerTitle!!field}}>\n\n!some heading</div></div>")).toEqual(
[ { type : 'element', tag : 'p', start: 0, end: 71, children : [ { type : 'element', start : 0, attributes : { }, orderedAttributes: [ ], tag : 'div', end : 5, isBlock : false, children : [ { type : 'element', start : 5, attributes : { attribute : { start : 9, name : 'attribute', type : 'indirect', textReference : 'TiddlerTitle!!field', end : 43 } }, orderedAttributes: [ { start : 9, name : 'attribute', type : 'indirect', textReference : 'TiddlerTitle!!field', end : 43 } ], tag : 'div', end : 44, isBlock : true, children : [ { type : 'element', tag : 'h1', attributes : { class : { type : 'string', value : '' } }, children : [ { type : 'text', text : 'some heading</div></div>', start : 47, end : 71 } ] } ] } ] } ] } ]
[ { type : 'element', start : 0, attributes : { }, orderedAttributes: [ ], tag : 'div', end : 5, isBlock : false, children : [ { type : 'element', start : 5, attributes : { attribute : { start : 9, name : 'attribute', type : 'indirect', textReference : 'TiddlerTitle!!field', end : 43 } }, orderedAttributes: [ { start : 9, name : 'attribute', type : 'indirect', textReference : 'TiddlerTitle!!field', end : 43 } ], tag : 'div', end : 44, isBlock : true, children : [ { type : 'element', tag : 'h1', attributes : { class : { type : 'string', value : '' } }, children : [ { type : 'text', text : 'some heading</div></div>', start : 47, end : 71 } ] } ] } ] } ]
);
expect(parse("<div><div attribute={{TiddlerTitle!!field}}>\n!some heading</div></div>")).toEqual(
[ { type : 'element', tag : 'p', start: 0, end: 70, children : [ { type : 'element', start : 0, attributes : { }, orderedAttributes: [ ], tag : 'div', end : 5, isBlock : false, children : [ { type : 'element', start : 5, attributes : { attribute : { start : 9, name : 'attribute', type : 'indirect', textReference : 'TiddlerTitle!!field', end : 43 } }, orderedAttributes: [ { start : 9, name : 'attribute', type : 'indirect', textReference : 'TiddlerTitle!!field', end : 43 } ], tag : 'div', end : 44, isBlock : false, children : [ { type : 'text', text : '\n!some heading', start : 44, end : 58 } ] } ] } ] } ]
[ { type : 'element', start : 0, attributes : { }, orderedAttributes: [ ], tag : 'div', end : 5, isBlock : false, children : [ { type : 'element', start : 5, attributes : { attribute : { start : 9, name : 'attribute', type : 'indirect', textReference : 'TiddlerTitle!!field', end : 43 } }, orderedAttributes: [ { start : 9, name : 'attribute', type : 'indirect', textReference : 'TiddlerTitle!!field', end : 43 } ], tag : 'div', end : 44, isBlock : false, children : [ { type : 'text', text : '\n!some heading', start : 44, end : 58 } ] } ] } ]
);
// Regression test for issue (#3306)
expect(parse("<div><span><span>\n\nSome text</span></span></div>")).toEqual(
[ { type : 'element', tag : 'p', start: 0, end: 48, children : [ { type : 'element', start : 0, attributes : { }, orderedAttributes: [ ], tag : 'div', end : 5, isBlock : false, children : [ { type : 'element', start : 5, attributes : { }, orderedAttributes: [ ], tag : 'span', end : 11, isBlock : false, children : [ { type : 'element', start : 11, attributes : { }, orderedAttributes: [ ], tag : 'span', end : 17, isBlock : true, children : [ { type : 'element', tag : 'p', start : 19, end : 28, children : [ { type : 'text', text : 'Some text', start : 19, end : 28 } ] } ] } ] } ] } ] } ]
[ { type : 'element', start : 0, attributes : { }, orderedAttributes: [ ], tag : 'div', end : 5, isBlock : false, children : [ { type : 'element', start : 5, attributes : { }, orderedAttributes: [ ], tag : 'span', end : 11, isBlock : false, children : [ { type : 'element', start : 11, attributes : { }, orderedAttributes: [ ], tag : 'span', end : 17, isBlock : true, children : [ { type : 'element', tag : 'p', start : 19, end : 28, children : [ { type : 'text', text : 'Some text', start : 19, end : 28 } ] } ] } ] } ] } ]
);
});
@ -207,13 +207,30 @@ describe("WikiText parser tests", function() {
it("should parse inline macro calls", function() {
expect(parse("<<john>><<paul>><<george>><<ringo>>")).toEqual(
[{"type":"element","tag":"p","children":[{"type":"transclude","start":0,"end":8,"attributes":{"$variable":{"name":"$variable","type":"string","value":"john"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"john"}]},{"type":"transclude","start":8,"end":16,"attributes":{"$variable":{"name":"$variable","type":"string","value":"paul"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"paul"}]},{"type":"transclude","start":16,"end":26,"attributes":{"$variable":{"name":"$variable","type":"string","value":"george"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"george"}]},{"type":"transclude","start":26,"end":35,"attributes":{"$variable":{"name":"$variable","type":"string","value":"ringo"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"ringo"}]}],"start":0,"end":35}]
[{"type":"transclude","start":0,"end":8,"attributes":{"$variable":{"name":"$variable","type":"string","value":"john"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"john"}]},{"type":"transclude","start":8,"end":16,"attributes":{"$variable":{"name":"$variable","type":"string","value":"paul"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"paul"}]},{"type":"transclude","start":16,"end":26,"attributes":{"$variable":{"name":"$variable","type":"string","value":"george"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"george"}]},{"type":"transclude","start":26,"end":35,"attributes":{"$variable":{"name":"$variable","type":"string","value":"ringo"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"ringo"}]}]
);
expect(parse("text <<john one:val1 two: 'val \"2\"' three: \"val '3'\" four: \"\"\"val 4\"5'\"\"\" five: [[val 5]] >>")).toEqual(
[{"type":"element","tag":"p","children":[{"type":"text","text":"text ","start":0,"end":5},{"type":"transclude","start":5,"end":92,"attributes":{"$variable":{"name":"$variable","type":"string","value":"john"},"one":{"name":"one","type":"string","value":"val1","start":11,"end":20},"two":{"name":"two","type":"string","value":"val \"2\"","start":20,"end":35},"three":{"name":"three","type":"string","value":"val '3'","start":35,"end":52},"four":{"name":"four","type":"string","value":"val 4\"5'","start":52,"end":73},"five":{"name":"five","type":"string","value":"val 5","start":73,"end":89}},"orderedAttributes":[{"name":"$variable","type":"string","value":"john"},{"name":"one","type":"string","value":"val1","start":11,"end":20},{"name":"two","type":"string","value":"val \"2\"","start":20,"end":35},{"name":"three","type":"string","value":"val '3'","start":35,"end":52},{"name":"four","type":"string","value":"val 4\"5'","start":52,"end":73},{"name":"five","type":"string","value":"val 5","start":73,"end":89}]}],"start":0,"end":92}]
[{"type": "element","tag": "p", "children": [
{"type": "text","text": "text ","start": 0, "end": 5},
{"type": "transclude","start": 5,"end": 92,
"attributes": { "$variable": { "name": "$variable", "type": "string","value": "john"},
"one": {"name": "one","type": "string","value": "val1","start": 11, "end": 20},
"two": {"name": "two","type": "string","value": "val \"2\"","start": 20,"end": 35},
"three": {"name": "three","type": "string","value": "val '3'","start": 35,"end": 52},
"four": {"name": "four","type": "string","value": "val 4\"5'","start": 52,"end": 73},
"five": {"name": "five","type": "string","value": "val 5","start": 73,"end": 89}},
"orderedAttributes":
[{ "name": "$variable","type": "string","value": "john"},
{"name": "one", "type": "string","value": "val1","start": 11,"end": 20},
{"name": "two","type": "string","value": "val \"2\"","start": 20,"end": 35},
{"name": "three","type": "string","value": "val '3'","start": 35,"end": 52},
{"name": "four","type": "string","value": "val 4\"5'","start": 52,"end": 73},
{"name": "five","type": "string","value": "val 5","start": 73,"end": 89}
]}],
"start": 0,"end": 92
}]
);
expect(parse("ignored << carrots <<john>>")).toEqual(

View File

@ -43,7 +43,7 @@ describe("WikiText tests", function() {
expect(wiki.renderTiddler("text/html","TiddlerThree")).toBe("<p>The speed of sound</p><p>The light of speed</p>");
});
it("should support attributes specified as macro invocations", function() {
expect(wiki.renderTiddler("text/html","TiddlerFour")).toBe("<p><a class=\"tc-tiddlylink tc-tiddlylink-missing\" href=\"#This%20is%20my%20%27%27amazingly%27%27%20groovy%20macro%21\">This is a link</a></p>");
expect(wiki.renderTiddler("text/html","TiddlerFour")).toBe("<a class=\"tc-tiddlylink tc-tiddlylink-missing\" href=\"#This%20is%20my%20%27%27amazingly%27%27%20groovy%20macro%21\">This is a link</a>");
});
it("handles style wikitext notation", function() {
expect(wiki.renderText("text/html","text/vnd-tiddlywiki","@@.myclass\n!header\n@@")).toBe("<h1 class=\"myclass\">header</h1>");