mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-30 05:19:57 +00:00
Fix test rig shadow tiddler behaviour
The test rig previously used a simplified implementation of shadow tiddlers which broke with the new indexing engine. There was also a problem that made that even if indexers were disabled they were still initialised. This PR fixes both problems, in preparation for fixing #4082
This commit is contained in:
parent
5d36b484c6
commit
cbd07465f3
@ -1013,7 +1013,7 @@ $tw.modules.define("$:/boot/tiddlerfields/list","tiddlerfield",{
|
|||||||
/*
|
/*
|
||||||
Wiki constructor. State is stored in private members that only a small number of privileged accessor methods have direct access. Methods added via the prototype have to use these accessors and cannot access the state data directly.
|
Wiki constructor. State is stored in private members that only a small number of privileged accessor methods have direct access. Methods added via the prototype have to use these accessors and cannot access the state data directly.
|
||||||
options include:
|
options include:
|
||||||
shadowTiddlers: Array of shadow tiddlers to be added
|
enableIndexers - Array of indexer names to enable, or null to use all available indexers
|
||||||
*/
|
*/
|
||||||
$tw.Wiki = function(options) {
|
$tw.Wiki = function(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
@ -1028,7 +1028,7 @@ $tw.Wiki = function(options) {
|
|||||||
},
|
},
|
||||||
pluginTiddlers = [], // Array of tiddlers containing registered plugins, ordered by priority
|
pluginTiddlers = [], // Array of tiddlers containing registered plugins, ordered by priority
|
||||||
pluginInfo = Object.create(null), // Hashmap of parsed plugin content
|
pluginInfo = Object.create(null), // Hashmap of parsed plugin content
|
||||||
shadowTiddlers = options.shadowTiddlers || Object.create(null), // Hashmap by title of {source:, tiddler:}
|
shadowTiddlers = Object.create(null), // Hashmap by title of {source:, tiddler:}
|
||||||
shadowTiddlerTitles = null,
|
shadowTiddlerTitles = null,
|
||||||
getShadowTiddlerTitles = function() {
|
getShadowTiddlerTitles = function() {
|
||||||
if(!shadowTiddlerTitles) {
|
if(!shadowTiddlerTitles) {
|
||||||
@ -1036,7 +1036,7 @@ $tw.Wiki = function(options) {
|
|||||||
}
|
}
|
||||||
return shadowTiddlerTitles;
|
return shadowTiddlerTitles;
|
||||||
},
|
},
|
||||||
enableIndexers = options.enableIndexers || null, // Array of indexer names to enable, or null to use all available indexers
|
enableIndexers = options.enableIndexers || null,
|
||||||
indexers = [],
|
indexers = [],
|
||||||
indexersByName = Object.create(null);
|
indexersByName = Object.create(null);
|
||||||
|
|
||||||
@ -1047,6 +1047,7 @@ $tw.Wiki = function(options) {
|
|||||||
}
|
}
|
||||||
indexers.push(indexer);
|
indexers.push(indexer);
|
||||||
indexersByName[name] = indexer;
|
indexersByName[name] = indexer;
|
||||||
|
indexer.init();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getIndexer = function(name) {
|
this.getIndexer = function(name) {
|
||||||
|
@ -16,6 +16,9 @@ var DEFAULT_MAXIMUM_INDEXED_VALUE_LENGTH = 128;
|
|||||||
|
|
||||||
function FieldIndexer(wiki) {
|
function FieldIndexer(wiki) {
|
||||||
this.wiki = wiki;
|
this.wiki = wiki;
|
||||||
|
}
|
||||||
|
|
||||||
|
FieldIndexer.prototype.init = function() {
|
||||||
this.index = null;
|
this.index = null;
|
||||||
this.maxIndexedValueLength = DEFAULT_MAXIMUM_INDEXED_VALUE_LENGTH;
|
this.maxIndexedValueLength = DEFAULT_MAXIMUM_INDEXED_VALUE_LENGTH;
|
||||||
this.addIndexMethods();
|
this.addIndexMethods();
|
||||||
|
@ -14,7 +14,10 @@ Indexes the tiddlers with each tag
|
|||||||
|
|
||||||
function TagIndexer(wiki) {
|
function TagIndexer(wiki) {
|
||||||
this.wiki = wiki;
|
this.wiki = wiki;
|
||||||
this.index = null;
|
}
|
||||||
|
|
||||||
|
TagIndexer.prototype.init = function() {
|
||||||
|
this.index = null; // Hashmap of tag title to {isSorted: bool, titles: [array]}
|
||||||
this.addIndexMethods();
|
this.addIndexMethods();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,48 +35,55 @@ describe("Filter tests", function() {
|
|||||||
|
|
||||||
describe("With no indexers", function() {
|
describe("With no indexers", function() {
|
||||||
var wiki = setupWiki({enableIndexers: []});
|
var wiki = setupWiki({enableIndexers: []});
|
||||||
|
it("should not create indexes when requested not to",function() {
|
||||||
|
expect(wiki.getIndexer("FieldIndexer")).toBe(null);
|
||||||
|
});
|
||||||
runTests(wiki);
|
runTests(wiki);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("With all indexers", function() {
|
describe("With all indexers", function() {
|
||||||
var wiki = setupWiki();
|
var wiki = setupWiki();
|
||||||
|
if(wiki.getIndexer("FieldIndexer")) {
|
||||||
wiki.getIndexer("FieldIndexer").setMaxIndexedValueLength(8); // Note that JoeBloggs is 9, and JohnDoe is 7
|
wiki.getIndexer("FieldIndexer").setMaxIndexedValueLength(8); // Note that JoeBloggs is 9, and JohnDoe is 7
|
||||||
|
}
|
||||||
runTests(wiki);
|
runTests(wiki);
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupWiki(wikiOptions) {
|
function setupWiki(wikiOptions) {
|
||||||
// Create a wiki
|
// Create a wiki
|
||||||
var wiki = new $tw.Wiki($tw.utils.extend({
|
var wiki = new $tw.Wiki(wikiOptions);
|
||||||
shadowTiddlers: {
|
// Add a plugin containing some shadow tiddlers
|
||||||
|
var shadowTiddlers = {
|
||||||
|
tiddlers: {
|
||||||
"$:/TiddlerFive": {
|
"$:/TiddlerFive": {
|
||||||
tiddler: new $tw.Tiddler({title: "$:/TiddlerFive",
|
title: "$:/TiddlerFive",
|
||||||
text: "Everything in federation",
|
text: "Everything in federation",
|
||||||
tags: ["two"]
|
tags: ["two"]
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
"TiddlerSix": {
|
"TiddlerSix": {
|
||||||
tiddler: new $tw.Tiddler({title: "TiddlerSix",
|
title: "TiddlerSix",
|
||||||
text: "Missing inaction from TiddlerOne",
|
text: "Missing inaction from TiddlerOne",
|
||||||
tags: []
|
tags: []
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
"TiddlerSeventh": {
|
"TiddlerSeventh": {
|
||||||
tiddler: new $tw.Tiddler({title: "TiddlerSeventh",
|
title: "TiddlerSeventh",
|
||||||
text: "",
|
text: "",
|
||||||
list: "TiddlerOne [[Tiddler Three]] [[a fourth tiddler]] MissingTiddler",
|
list: "TiddlerOne [[Tiddler Three]] [[a fourth tiddler]] MissingTiddler",
|
||||||
tags: ["one"]
|
tags: ["one"]
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
"Tiddler8": {
|
"Tiddler8": {
|
||||||
tiddler: new $tw.Tiddler({title: "Tiddler8",
|
title: "Tiddler8",
|
||||||
text: "Tidd",
|
text: "Tidd",
|
||||||
tags: ["one"],
|
tags: ["one"],
|
||||||
"test-field": "JoeBloggs"
|
"test-field": "JoeBloggs"
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
wikiOptions));
|
wiki.addTiddler({
|
||||||
|
title: "$:/ShadowPlugin",
|
||||||
|
text: JSON.stringify(shadowTiddlers),
|
||||||
|
"plugin-type": "plugin",
|
||||||
|
type: "application/json"});
|
||||||
// Add a few tiddlers
|
// Add a few tiddlers
|
||||||
wiki.addTiddler({
|
wiki.addTiddler({
|
||||||
title: "TiddlerOne",
|
title: "TiddlerOne",
|
||||||
@ -110,6 +117,11 @@ function setupWiki(wikiOptions) {
|
|||||||
list: "[[Tiddler Three]] [[TiddlerOne]]",
|
list: "[[Tiddler Three]] [[TiddlerOne]]",
|
||||||
empty: "",
|
empty: "",
|
||||||
modifier: "JohnDoe"});
|
modifier: "JohnDoe"});
|
||||||
|
// Unpack plugin tiddlers
|
||||||
|
wiki.readPluginInfo();
|
||||||
|
wiki.registerPluginTiddlers("plugin");
|
||||||
|
wiki.unpackPluginTiddlers();
|
||||||
|
wiki.addIndexersToWiki();
|
||||||
return wiki;
|
return wiki;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,31 +146,31 @@ function runTests(wiki) {
|
|||||||
|
|
||||||
it("should handle the title operator", function() {
|
it("should handle the title operator", function() {
|
||||||
expect(wiki.filterTiddlers("TiddlerOne [title[$:/TiddlerTwo]] [[Tiddler Three]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three");
|
expect(wiki.filterTiddlers("TiddlerOne [title[$:/TiddlerTwo]] [[Tiddler Three]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three");
|
||||||
expect(wiki.filterTiddlers("[!title[Tiddler Three]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[!title[Tiddler Three]]").join(",")).toBe("$:/ShadowPlugin,TiddlerOne,$:/TiddlerTwo,a fourth tiddler,one");
|
||||||
expect(wiki.filterTiddlers("TiddlerOne [title[$:/TiddlerTwo]] [[Tiddler Three]] [[A Missing Tiddler]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three,A Missing Tiddler");
|
expect(wiki.filterTiddlers("TiddlerOne [title[$:/TiddlerTwo]] [[Tiddler Three]] [[A Missing Tiddler]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three,A Missing Tiddler");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the field operator", function() {
|
it("should handle the field operator", function() {
|
||||||
expect(wiki.filterTiddlers("[modifier[JoeBloggs]]").join(",")).toBe("TiddlerOne");
|
expect(wiki.filterTiddlers("[modifier[JoeBloggs]]").join(",")).toBe("TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[!modifier[JoeBloggs]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[!modifier[JoeBloggs]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,Tiddler Three,a fourth tiddler,one");
|
||||||
expect(wiki.filterTiddlers("[!is[system]!modifier[JoeBloggs]]").join(",")).toBe("Tiddler Three,a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[!is[system]!modifier[JoeBloggs]]").join(",")).toBe("Tiddler Three,a fourth tiddler,one");
|
||||||
expect(wiki.filterTiddlers("[field:modifier[JoeBloggs]]").join(",")).toBe("TiddlerOne");
|
expect(wiki.filterTiddlers("[field:modifier[JoeBloggs]]").join(",")).toBe("TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[!field:modifier[JoeBloggs]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[!field:modifier[JoeBloggs]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,Tiddler Three,a fourth tiddler,one");
|
||||||
expect(wiki.filterTiddlers("[!is[system]!field:modifier[JoeBloggs]]").join(",")).toBe("Tiddler Three,a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[!is[system]!field:modifier[JoeBloggs]]").join(",")).toBe("Tiddler Three,a fourth tiddler,one");
|
||||||
expect(wiki.filterTiddlers("[modifier[JohnDoe]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[modifier[JohnDoe]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,a fourth tiddler,one");
|
||||||
expect(wiki.filterTiddlers("[!modifier[JohnDoe]]").join(",")).toBe("TiddlerOne");
|
expect(wiki.filterTiddlers("[!modifier[JohnDoe]]").join(",")).toBe("$:/ShadowPlugin,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[!is[system]!modifier[JohnDoe]]").join(",")).toBe("TiddlerOne");
|
expect(wiki.filterTiddlers("[!is[system]!modifier[JohnDoe]]").join(",")).toBe("TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[field:modifier[JohnDoe]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[field:modifier[JohnDoe]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,a fourth tiddler,one");
|
||||||
expect(wiki.filterTiddlers("[!field:modifier[JohnDoe]]").join(",")).toBe("TiddlerOne");
|
expect(wiki.filterTiddlers("[!field:modifier[JohnDoe]]").join(",")).toBe("$:/ShadowPlugin,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[!is[system]!field:modifier[JohnDoe]]").join(",")).toBe("TiddlerOne");
|
expect(wiki.filterTiddlers("[!is[system]!field:modifier[JohnDoe]]").join(",")).toBe("TiddlerOne");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the regexp operator", function() {
|
it("should handle the regexp operator", function() {
|
||||||
expect(wiki.filterTiddlers("[regexp[id]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three,a fourth tiddler");
|
expect(wiki.filterTiddlers("[regexp[id]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three,a fourth tiddler");
|
||||||
expect(wiki.filterTiddlers("[!regexp[id]]").join(",")).toBe("one");
|
expect(wiki.filterTiddlers("[!regexp[id]]").join(",")).toBe("$:/ShadowPlugin,one");
|
||||||
expect(wiki.filterTiddlers("[regexp[Tid]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three");
|
expect(wiki.filterTiddlers("[regexp[Tid]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three");
|
||||||
expect(wiki.filterTiddlers("[regexp[(?i)Tid]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three,a fourth tiddler");
|
expect(wiki.filterTiddlers("[regexp[(?i)Tid]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three,a fourth tiddler");
|
||||||
expect(wiki.filterTiddlers("[!regexp[Tid(?i)]]").join(",")).toBe("one");
|
expect(wiki.filterTiddlers("[!regexp[Tid(?i)]]").join(",")).toBe("$:/ShadowPlugin,one");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the field operator with a regular expression operand", function() {
|
it("should handle the field operator with a regular expression operand", function() {
|
||||||
@ -172,41 +184,41 @@ function runTests(wiki) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the sort and sortcs operators", function() {
|
it("should handle the sort and sortcs operators", function() {
|
||||||
expect(wiki.filterTiddlers("[sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[!sort[title]]").join(",")).toBe("TiddlerOne,Tiddler Three,one,a fourth tiddler,$:/TiddlerTwo");
|
expect(wiki.filterTiddlers("[!sort[title]]").join(",")).toBe("TiddlerOne,Tiddler Three,one,a fourth tiddler,$:/TiddlerTwo,$:/ShadowPlugin");
|
||||||
// Temporarily commenting out the following two lines because of platform differences for localeCompare between the browser and Node.js
|
// Temporarily commenting out the following two lines because of platform differences for localeCompare between the browser and Node.js
|
||||||
// expect(wiki.filterTiddlers("[sortcs[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne,a fourth tiddler,one");
|
// expect(wiki.filterTiddlers("[sortcs[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne,a fourth tiddler,one");
|
||||||
// expect(wiki.filterTiddlers("[!sortcs[title]]").join(",")).toBe("one,a fourth tiddler,TiddlerOne,Tiddler Three,$:/TiddlerTwo");
|
// expect(wiki.filterTiddlers("[!sortcs[title]]").join(",")).toBe("one,a fourth tiddler,TiddlerOne,Tiddler Three,$:/TiddlerTwo");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the reverse, first, last, butfirst, butlast, rest and nth operators", function() {
|
it("should handle the reverse, first, last, butfirst, butlast, rest and nth operators", function() {
|
||||||
expect(wiki.filterTiddlers("[sort[title]first[]]").join(",")).toBe("$:/TiddlerTwo");
|
expect(wiki.filterTiddlers("[sort[title]first[]]").join(",")).toBe("$:/ShadowPlugin");
|
||||||
expect(wiki.filterTiddlers("[sort[title]first[2]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler");
|
expect(wiki.filterTiddlers("[sort[title]first[2]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo");
|
||||||
expect(wiki.filterTiddlers("[sort[title]first[8]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[sort[title]first[8]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[sort[title]first[x]]").join(",")).toBe("$:/TiddlerTwo");
|
expect(wiki.filterTiddlers("[sort[title]first[x]]").join(",")).toBe("$:/ShadowPlugin");
|
||||||
expect(wiki.filterTiddlers("[sort[title]last[]]").join(",")).toBe("TiddlerOne");
|
expect(wiki.filterTiddlers("[sort[title]last[]]").join(",")).toBe("TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[sort[title]last[2]]").join(",")).toBe("Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[sort[title]last[2]]").join(",")).toBe("Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[sort[title]last[8]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[sort[title]last[8]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[sort[title]last[x]]").join(",")).toBe("TiddlerOne");
|
expect(wiki.filterTiddlers("[sort[title]last[x]]").join(",")).toBe("TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[sort[title]reverse[]]").join(",")).toBe("TiddlerOne,Tiddler Three,one,a fourth tiddler,$:/TiddlerTwo");
|
expect(wiki.filterTiddlers("[sort[title]reverse[]]").join(",")).toBe("TiddlerOne,Tiddler Three,one,a fourth tiddler,$:/TiddlerTwo,$:/ShadowPlugin");
|
||||||
expect(wiki.filterTiddlers("[sort[title]reverse[x]]").join(",")).toBe("TiddlerOne,Tiddler Three,one,a fourth tiddler,$:/TiddlerTwo");
|
expect(wiki.filterTiddlers("[sort[title]reverse[x]]").join(",")).toBe("TiddlerOne,Tiddler Three,one,a fourth tiddler,$:/TiddlerTwo,$:/ShadowPlugin");
|
||||||
expect(wiki.filterTiddlers("[sort[title]butlast[]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three");
|
expect(wiki.filterTiddlers("[sort[title]butlast[]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three");
|
||||||
expect(wiki.filterTiddlers("[sort[title]butlast[2]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[sort[title]butlast[2]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,one");
|
||||||
expect(wiki.filterTiddlers("[sort[title]butlast[8]]").join(",")).toBe("");
|
expect(wiki.filterTiddlers("[sort[title]butlast[8]]").join(",")).toBe("");
|
||||||
expect(wiki.filterTiddlers("[sort[title]butlast[x]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three");
|
expect(wiki.filterTiddlers("[sort[title]butlast[x]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three");
|
||||||
expect(wiki.filterTiddlers("[sort[title]rest[]]").join(",")).toBe("a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[sort[title]rest[]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[sort[title]rest[2]]").join(",")).toBe("one,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[sort[title]rest[2]]").join(",")).toBe("a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[sort[title]rest[8]]").join(",")).toBe("");
|
expect(wiki.filterTiddlers("[sort[title]rest[8]]").join(",")).toBe("");
|
||||||
expect(wiki.filterTiddlers("[sort[title]rest[x]]").join(",")).toBe("a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[sort[title]rest[x]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[sort[title]nth[]]").join(",")).toBe("$:/TiddlerTwo");
|
expect(wiki.filterTiddlers("[sort[title]nth[]]").join(",")).toBe("$:/ShadowPlugin");
|
||||||
expect(wiki.filterTiddlers("[sort[title]nth[2]]").join(",")).toBe("a fourth tiddler");
|
expect(wiki.filterTiddlers("[sort[title]nth[2]]").join(",")).toBe("$:/TiddlerTwo");
|
||||||
expect(wiki.filterTiddlers("[sort[title]nth[8]]").join(",")).toBe("");
|
expect(wiki.filterTiddlers("[sort[title]nth[8]]").join(",")).toBe("");
|
||||||
expect(wiki.filterTiddlers("[sort[title]nth[x]]").join(",")).toBe("$:/TiddlerTwo");
|
expect(wiki.filterTiddlers("[sort[title]nth[x]]").join(",")).toBe("$:/ShadowPlugin");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the tag operator", function() {
|
it("should handle the tag operator", function() {
|
||||||
expect(wiki.filterTiddlers("[tag[one]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[tag[one]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[!tag[one]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[!tag[one]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,one");
|
||||||
expect(wiki.filterTiddlers("[prefix[Tidd]tag[one]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[prefix[Tidd]tag[one]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[!is[shadow]tag[two]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three");
|
expect(wiki.filterTiddlers("[!is[shadow]tag[two]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three");
|
||||||
expect(wiki.filterTiddlers("[all[shadows]tag[two]sort[title]]").join(",")).toBe("$:/TiddlerFive");
|
expect(wiki.filterTiddlers("[all[shadows]tag[two]sort[title]]").join(",")).toBe("$:/TiddlerFive");
|
||||||
@ -226,7 +238,7 @@ function runTests(wiki) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the untagged operator", function() {
|
it("should handle the untagged operator", function() {
|
||||||
expect(wiki.filterTiddlers("[untagged[]sort[title]]").join(",")).toBe("a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[untagged[]sort[title]]").join(",")).toBe("$:/ShadowPlugin,a fourth tiddler,one");
|
||||||
expect(wiki.filterTiddlers("[!untagged[]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[!untagged[]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -242,12 +254,12 @@ function runTests(wiki) {
|
|||||||
|
|
||||||
it("should handle the has operator", function() {
|
it("should handle the has operator", function() {
|
||||||
expect(wiki.filterTiddlers("[has[modified]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[has[modified]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[!has[modified]sort[title]]").join(",")).toBe("a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[!has[modified]sort[title]]").join(",")).toBe("$:/ShadowPlugin,a fourth tiddler,one");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the has:field operator", function() {
|
it("should handle the has:field operator", function() {
|
||||||
expect(wiki.filterTiddlers("[has:field[empty]sort[title]]").join(",")).toBe("a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[has:field[empty]sort[title]]").join(",")).toBe("a fourth tiddler,one");
|
||||||
expect(wiki.filterTiddlers("[!has:field[empty]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[!has:field[empty]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,Tiddler Three,TiddlerOne");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -274,14 +286,14 @@ function runTests(wiki) {
|
|||||||
|
|
||||||
it("should handle the search operator", function() {
|
it("should handle the search operator", function() {
|
||||||
expect(wiki.filterTiddlers("[search[the]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[search[the]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[search{Tiddler8}sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[search{Tiddler8}sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[search:modifier[og]sort[title]]").join(",")).toBe("TiddlerOne");
|
expect(wiki.filterTiddlers("[search:modifier[og]sort[title]]").join(",")).toBe("TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[search:modifier,authors:casesensitive[Do]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three");
|
expect(wiki.filterTiddlers("[search:modifier,authors:casesensitive[Do]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three");
|
||||||
expect(wiki.filterTiddlers("[search:modifier,authors:casesensitive[do]sort[title]]").join(",")).toBe("");
|
expect(wiki.filterTiddlers("[search:modifier,authors:casesensitive[do]sort[title]]").join(",")).toBe("");
|
||||||
expect(wiki.filterTiddlers("[search:authors:casesensitive,whitespace[John Doe]sort[title]]").join(",")).toBe("$:/TiddlerTwo");
|
expect(wiki.filterTiddlers("[search:authors:casesensitive,whitespace[John Doe]sort[title]]").join(",")).toBe("$:/TiddlerTwo");
|
||||||
expect(wiki.filterTiddlers("[search:modifier:regexp[(d|bl)o(ggs|e)]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[search:modifier:regexp[(d|bl)o(ggs|e)]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[search:-modifier,authors:[g]sort[title]]").join(",")).toBe("Tiddler Three");
|
expect(wiki.filterTiddlers("[search:-modifier,authors:[g]sort[title]]").join(",")).toBe("$:/ShadowPlugin,Tiddler Three");
|
||||||
expect(wiki.filterTiddlers("[search:*:[g]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[search:*:[g]sort[title]]").join(",")).toBe("$:/ShadowPlugin,Tiddler Three,TiddlerOne");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should yield search results that have search tokens spread across different fields", function() {
|
it("should yield search results that have search tokens spread across different fields", function() {
|
||||||
@ -289,7 +301,7 @@ function runTests(wiki) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the each operator", function() {
|
it("should handle the each operator", function() {
|
||||||
expect(wiki.filterTiddlers("[each[modifier]sort[title]]").join(",")).toBe("$:/TiddlerTwo,TiddlerOne");
|
expect(wiki.filterTiddlers("[each[modifier]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[each:list-item[tags]sort[title]]").join(",")).toBe("one,two");
|
expect(wiki.filterTiddlers("[each:list-item[tags]sort[title]]").join(",")).toBe("one,two");
|
||||||
expect(wiki.filterTiddlers("[each:list-item[authors]sort[title]]").join(",")).toBe("Bloggs,Joe,John Doe");
|
expect(wiki.filterTiddlers("[each:list-item[authors]sort[title]]").join(",")).toBe("Bloggs,Joe,John Doe");
|
||||||
});
|
});
|
||||||
@ -309,36 +321,36 @@ function runTests(wiki) {
|
|||||||
expect(wiki.filterTiddlers("[is[current]]",fakeWidget).join(",")).toBe("Tiddler Three");
|
expect(wiki.filterTiddlers("[is[current]]",fakeWidget).join(",")).toBe("Tiddler Three");
|
||||||
expect(wiki.filterTiddlers("[[Tiddler Three]is[current]]",fakeWidget).join(",")).toBe("Tiddler Three");
|
expect(wiki.filterTiddlers("[[Tiddler Three]is[current]]",fakeWidget).join(",")).toBe("Tiddler Three");
|
||||||
expect(wiki.filterTiddlers("[[$:/TiddlerTwo]is[current]]",fakeWidget).join(",")).toBe("");
|
expect(wiki.filterTiddlers("[[$:/TiddlerTwo]is[current]]",fakeWidget).join(",")).toBe("");
|
||||||
expect(wiki.filterTiddlers("[!is[current]sort[title]]",fakeWidget).join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,TiddlerOne");
|
expect(wiki.filterTiddlers("[!is[current]sort[title]]",fakeWidget).join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,one,TiddlerOne");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the '[is[system]]' operator", function() {
|
it("should handle the '[is[system]]' operator", function() {
|
||||||
expect(wiki.filterTiddlers("[is[system]]").join(",")).toBe("$:/TiddlerTwo");
|
expect(wiki.filterTiddlers("[is[system]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo");
|
||||||
expect(wiki.filterTiddlers("[!is[system]sort[title]]").join(",")).toBe("a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[!is[system]sort[title]]").join(",")).toBe("a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the '[is[shadow]]' operator", function() {
|
it("should handle the '[is[shadow]]' operator", function() {
|
||||||
expect(wiki.filterTiddlers("[all[shadows]sort[title]]").join(",")).toBe("$:/TiddlerFive,Tiddler8,TiddlerSeventh,TiddlerSix");
|
expect(wiki.filterTiddlers("[all[shadows]sort[title]]").join(",")).toBe("$:/TiddlerFive,Tiddler8,TiddlerSeventh,TiddlerSix");
|
||||||
expect(wiki.filterTiddlers("[!is[shadow]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[!is[shadow]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the '[is[missing]]' operator", function() {
|
it("should handle the '[is[missing]]' operator", function() {
|
||||||
expect(wiki.filterTiddlers("[all[]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three,a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[all[]]").join(",")).toBe("$:/ShadowPlugin,TiddlerOne,$:/TiddlerTwo,Tiddler Three,a fourth tiddler,one");
|
||||||
expect(wiki.filterTiddlers("[all[missing]]").join(",")).toBe("TiddlerZero");
|
expect(wiki.filterTiddlers("[all[missing]]").join(",")).toBe("TiddlerZero");
|
||||||
expect(wiki.filterTiddlers("[!is[missing]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
expect(wiki.filterTiddlers("[!is[missing]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[[TiddlerOne]is[missing]]").join(",")).toBe("");
|
expect(wiki.filterTiddlers("[[TiddlerOne]is[missing]]").join(",")).toBe("");
|
||||||
expect(wiki.filterTiddlers("[[TiddlerZero]is[missing]]").join(",")).toBe("TiddlerZero");
|
expect(wiki.filterTiddlers("[[TiddlerZero]is[missing]]").join(",")).toBe("TiddlerZero");
|
||||||
expect(wiki.filterTiddlers("[!title[Tiddler Three]is[missing]]").join(",")).toBe("");
|
expect(wiki.filterTiddlers("[!title[Tiddler Three]is[missing]]").join(",")).toBe("");
|
||||||
expect(wiki.filterTiddlers("[!title[Tiddler Three]!is[missing]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,TiddlerOne");
|
expect(wiki.filterTiddlers("[!title[Tiddler Three]!is[missing]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,one,TiddlerOne");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the '[is[orphan]]' operator", function() {
|
it("should handle the '[is[orphan]]' operator", function() {
|
||||||
expect(wiki.filterTiddlers("[is[orphan]sort[title]]").join(",")).toBe("a fourth tiddler,TiddlerOne");
|
expect(wiki.filterTiddlers("[is[orphan]sort[title]]").join(",")).toBe("a fourth tiddler,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[!is[orphan]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,one");
|
expect(wiki.filterTiddlers("[!is[orphan]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,Tiddler Three,one");
|
||||||
expect(wiki.filterTiddlers("[[TiddlerOne]is[orphan]]").join(",")).toBe("TiddlerOne");
|
expect(wiki.filterTiddlers("[[TiddlerOne]is[orphan]]").join(",")).toBe("TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[[TiddlerOne]!is[orphan]]").join(",")).toBe("");
|
expect(wiki.filterTiddlers("[[TiddlerOne]!is[orphan]]").join(",")).toBe("");
|
||||||
expect(wiki.filterTiddlers("[!title[Tiddler Three]is[orphan]sort[title]]").join(",")).toBe("a fourth tiddler,TiddlerOne");
|
expect(wiki.filterTiddlers("[!title[Tiddler Three]is[orphan]sort[title]]").join(",")).toBe("a fourth tiddler,TiddlerOne");
|
||||||
expect(wiki.filterTiddlers("[!title[Tiddler Three]!is[orphan]]").join(",")).toBe("$:/TiddlerTwo,one");
|
expect(wiki.filterTiddlers("[!title[Tiddler Three]!is[orphan]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,one");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user