mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-17 03:20:02 +00:00
Joining an empty list should return an empty list (#4853)
This commit is contained in:
parent
72c07a3f81
commit
d5cf4112fa
@ -90,6 +90,9 @@ function makeStringReducingOperator(fnCalc,initialValue) {
|
||||
source(function(tiddler,title) {
|
||||
result.push(title);
|
||||
});
|
||||
if(result.length === 0) {
|
||||
return [];
|
||||
}
|
||||
return [result.reduce(function(accumulator,currentValue) {
|
||||
return fnCalc(accumulator,currentValue,operator.operand || "");
|
||||
},initialValue) || ""];
|
||||
|
@ -463,7 +463,7 @@ function runTests(wiki) {
|
||||
expect(wiki.filterTiddlers("John Paul George Ringo +[split[e]]").join(",")).toBe("John,Paul,G,org,,Ringo");
|
||||
expect(wiki.filterTiddlers("John Paul George Ringo +[join[ ]split[e]join[ee]split[ ]]").join(",")).toBe("John,Paul,Geeorgee,Ringo");
|
||||
// Ensure that join doesn't return null if passed empty list
|
||||
expect(wiki.filterTiddlers("Test +[butlast[]join[ ]]")).toEqual([""]);
|
||||
expect(wiki.filterTiddlers("Test +[butlast[]join[ ]]")).toEqual([]);
|
||||
// Ensure that join correctly handles empty strings in source
|
||||
expect(wiki.filterTiddlers("[[]] Paul +[join[-]]").join(",")).toBe("-Paul");
|
||||
expect(wiki.filterTiddlers("[[ John ]] [[Paul ]] [[ George]] Ringo +[trim[]join[-]]").join(",")).toBe("John-Paul-George-Ringo");
|
||||
|
Loading…
x
Reference in New Issue
Block a user