diff --git a/bin/test.cmd b/bin/test.cmd index 554277b57..4733f200e 100644 --- a/bin/test.cmd +++ b/bin/test.cmd @@ -4,8 +4,8 @@ rem test TiddlyWiki5 for tiddlywiki.com rem Run the test edition to run the node.js tests and to generate test.html for tests in the browser -node .\tiddlywiki.js ^ - .\editions\test ^ +node ..\tiddlywiki.js ^ + ..\editions\test ^ --verbose ^ --rendertiddler $:/core/save/all test.html text/plain ^ || exit 1 diff --git a/core/modules/filters/each.js b/core/modules/filters/each.js index 79a3981b9..a046923ad 100644 --- a/core/modules/filters/each.js +++ b/core/modules/filters/each.js @@ -20,16 +20,16 @@ exports.each = function(source,operator,options) { var results = [], values = {}, field = operator.operand || "title", - add = function(v) { - if(!$tw.utils.hop(values,v)) { - values[v] = true; - results.push(v); + add = function(val,title) { + if(!$tw.utils.hop(values,val)) { + values[val] = true; + results.push(title); } }; if("list" !== operator.suffix) { source(function(tiddler,title) { if(tiddler) { - add("title" === field ? title : tiddler.getFieldString(operator.operand)); + add("title" === field ? title : tiddler.getFieldString(field),title); } }); } else { @@ -38,7 +38,7 @@ exports.each = function(source,operator,options) { $tw.utils.each( options.wiki.getTiddlerList(title,field), function(value) { - add(value); + add(value,value); } ); } diff --git a/editions/test/tiddlers/tests/test-filters.js b/editions/test/tiddlers/tests/test-filters.js index 45ea8919e..1b16b117c 100644 --- a/editions/test/tiddlers/tests/test-filters.js +++ b/editions/test/tiddlers/tests/test-filters.js @@ -51,12 +51,14 @@ describe("Filter tests", function() { title: "TiddlerOne", text: "The quick brown fox in $:/TiddlerTwo", tags: ["one"], + authors: "Joe Bloggs", modifier: "JoeBloggs", modified: "201304152222"}); wiki.addTiddler({ title: "$:/TiddlerTwo", text: "The rain in Spain\nfalls mainly on the plain and [[a fourth tiddler]]", tags: ["two"], + authors: "[[John Doe]]", modifier: "JohnDoe", modified: "201304152211"}); wiki.addTiddler({ @@ -217,6 +219,8 @@ describe("Filter tests", function() { it("should handle the each operator", function() { expect(wiki.filterTiddlers("[each[modifier]sort[title]]").join(",")).toBe("$:/TiddlerTwo,TiddlerOne"); + expect(wiki.filterTiddlers("[each:list[tags]sort[title]]").join(",")).toBe("one,two"); + expect(wiki.filterTiddlers("[each:list[authors]sort[title]]").join(",")).toBe("Bloggs,Joe,John Doe"); }); it("should handle the eachday operator", function() {