-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unusedtitle macro tests - should have full code covery (#7939)
* add unusedtitle macro tests - should have full code covery * remove numbering from tests
- Loading branch information
Showing
8 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
editions/test/tiddlers/tests/data/macros/unusedtitle/basic-params-draft-exists.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
title: Macros/unusedtitle/basic-draft-exists | ||
description: test <<unusedtitle>> with basic macro parameters but they are empty | ||
type: text/vnd.tiddlywiki-multiple | ||
tags: [[$:/tags/wiki-test-spec]] | ||
|
||
title: Draft of 'test' | ||
draft.of: test | ||
draft.title: test | ||
|
||
+ | ||
title: Draft of 'asdf 0' | ||
draft.of: asdf 0 | ||
draft.title: asdf 0 | ||
|
||
+ | ||
title: Output | ||
|
||
<!-- hanled in wiki.js --> | ||
<<unusedtitle baseName:"test">> | ||
|
||
<!-- handled in unusedtitle.js --> | ||
<<unusedtitle baseName:"asdf" separator:" " template:"$basename$$separator$$count:1$">> | ||
|
||
+ | ||
title: ExpectedResult | ||
|
||
<p>test 1</p><p>asdf 1</p> |
23 changes: 23 additions & 0 deletions
23
editions/test/tiddlers/tests/data/macros/unusedtitle/basic-params-empty-tiddler-exists.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
title: Macros/unusedtitle/basic-params-empty-tiddler-exists | ||
description: test <<unusedtitle>> with basic macro parameters but they are empty | ||
type: text/vnd.tiddlywiki-multiple | ||
tags: [[$:/tags/wiki-test-spec]] | ||
|
||
title: New Tiddler | ||
|
||
+ | ||
title: Output | ||
|
||
<!-- hanled in wiki.js --> | ||
<<unusedtitle separator:"">> | ||
|
||
<!-- handled in unusedtitle.js --> | ||
<<unusedtitle baseName:"">> | ||
|
||
<!-- handled in wiki.js --> | ||
<<unusedtitle template:"">> | ||
|
||
+ | ||
title: ExpectedResult | ||
|
||
<p>New Tiddler 1</p><p>New Tiddler 1</p><p>New Tiddler 1</p> |
20 changes: 20 additions & 0 deletions
20
editions/test/tiddlers/tests/data/macros/unusedtitle/basic-params-empty.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
title: Macros/unusedtitle/basic-params-empty | ||
description: test <<unusedtitle>> with basic macro parameters but they are empty | ||
type: text/vnd.tiddlywiki-multiple | ||
tags: [[$:/tags/wiki-test-spec]] | ||
|
||
title: Output | ||
|
||
<!-- hanled in wiki.js --> | ||
<<unusedtitle separator:"">> | ||
|
||
<!-- handled in unusedtitle.js --> | ||
<<unusedtitle baseName:"">> | ||
|
||
<!-- handled in wiki.js --> | ||
<<unusedtitle template:"">> | ||
|
||
+ | ||
title: ExpectedResult | ||
|
||
<p>New Tiddler</p><p>New Tiddler</p><p>New Tiddler</p> |
28 changes: 28 additions & 0 deletions
28
editions/test/tiddlers/tests/data/macros/unusedtitle/basic-params-tiddlers-exist.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
title: Macros/unusedtitle/basic-params-tiddlers-exist | ||
description: test <<unusedtitle>> with basic macro parameters, where new-name tiddlers already exist | ||
type: text/vnd.tiddlywiki-multiple | ||
tags: [[$:/tags/wiki-test-spec]] | ||
|
||
title: New Tiddler | ||
|
||
+ | ||
title: anotherBase | ||
|
||
+ | ||
title: About | ||
|
||
+ | ||
title: Output | ||
|
||
<<unusedtitle>> | ||
|
||
<<unusedtitle separator:"-">> | ||
|
||
<<unusedtitle baseName:"anotherBase">> | ||
|
||
<<unusedtitle baseName:"About" separator:"-">> | ||
|
||
+ | ||
title: ExpectedResult | ||
|
||
<p>New Tiddler 1</p><p>New Tiddler-1</p><p>anotherBase 1</p><p>About-1</p> |
20 changes: 20 additions & 0 deletions
20
editions/test/tiddlers/tests/data/macros/unusedtitle/basic-params.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
title: Macros/unusedtitle/basic-params | ||
description: test <<unusedtitle>> with basic macro parameters | ||
type: text/vnd.tiddlywiki-multiple | ||
tags: [[$:/tags/wiki-test-spec]] | ||
|
||
title: Output | ||
|
||
<<unusedtitle>> | ||
|
||
<!-- EDGECASE: separator is ignored if tiddler title does not exist --> | ||
<<unusedtitle separator:"-">> | ||
|
||
<<unusedtitle baseName:"anotherBase">> | ||
|
||
<<unusedtitle baseName:"About" separator:"-">> | ||
|
||
+ | ||
title: ExpectedResult | ||
|
||
<p>New Tiddler</p><p>New Tiddler</p><p>anotherBase</p><p>About</p> |
50 changes: 50 additions & 0 deletions
50
editions/test/tiddlers/tests/data/macros/unusedtitle/template-empty-params-tiddler-exist.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
title: Macros/unusedtitle/template-empty-params-tiddler-exist | ||
description: test <<unusedtitle>> with templates where parameters are empty | ||
type: text/vnd.tiddlywiki-multiple | ||
tags: [[$:/tags/wiki-test-spec]] | ||
|
||
title: New Tiddler | ||
|
||
+ | ||
title: xxx | ||
|
||
+ | ||
title: 00-New Tiddler | ||
|
||
+ | ||
title: 0000 asdf | ||
|
||
+ | ||
title: 0001 asdf | ||
|
||
+ | ||
title: 0000 abc | ||
|
||
+ | ||
title: Output | ||
|
||
<!-- empty template - no template handling at all --> | ||
<<unusedtitle template:"">> | ||
|
||
<!-- | ||
uses basename AND separator if tiddler exists | ||
because it uses default naming build rules - no template handling | ||
--> | ||
<<unusedtitle template:"" separator:"-y-" baseName:"xxx">> | ||
|
||
<<unusedtitle baseName:"" template:"$count:2$-$basename$">> | ||
|
||
<!-- | ||
EDGECASE: if separator is empty it will be initialized with a single space " " | ||
to have the same rules for templates and default title creation | ||
--> | ||
<<unusedtitle baseName:"asdf" separator:"" template:"$count:4$$separator$$basename$">> | ||
|
||
<!-- separator = " " --> | ||
<<unusedtitle baseName:"abc" separator:" " template:"$count:4$$separator$$basename$">> | ||
|
||
|
||
+ | ||
title: ExpectedResult | ||
|
||
<p>New Tiddler 1</p><p>xxx-y-1</p><p>01-New Tiddler</p><p>0002 asdf</p><p>0001 abc</p> |
24 changes: 24 additions & 0 deletions
24
editions/test/tiddlers/tests/data/macros/unusedtitle/template-empty-params.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
title: Macros/unusedtitle/template-empty-params | ||
description: test <<unusedtitle>> with templates where parameters are empty | ||
type: text/vnd.tiddlywiki-multiple | ||
tags: [[$:/tags/wiki-test-spec]] | ||
|
||
title: Output | ||
|
||
<!-- empty template --> | ||
<<unusedtitle template:"">> | ||
|
||
<!-- | ||
uses basename but ignores separator, | ||
because it uses default naming build rules -- no template handling is active | ||
--> | ||
<<unusedtitle template:"" separator:"-x-" baseName:"xxx">> | ||
|
||
<<unusedtitle baseName:"" template:"$count:2$-$basename$">> | ||
|
||
<<unusedtitle baseName:"asdf" separator:"" template:"$count:4$$separator$$basename$">> | ||
|
||
+ | ||
title: ExpectedResult | ||
|
||
<p>New Tiddler</p><p>xxx</p><p>00-New Tiddler</p><p>0000 asdf</p> |
28 changes: 28 additions & 0 deletions
28
editions/test/tiddlers/tests/data/macros/unusedtitle/template.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
title: Macros/unusedtitle/template | ||
description: test <<unusedtitle>> with templates | ||
type: text/vnd.tiddlywiki-multiple | ||
tags: [[$:/tags/wiki-test-spec]] | ||
|
||
title: Output | ||
|
||
<!-- empty template - standard rules are used --> | ||
<<unusedtitle template:"">> | ||
|
||
<<unusedtitle template:"count-missing">> | ||
|
||
<<unusedtitle template:"$count:2$-new">> | ||
|
||
<!-- template is handled using $tw.utils.formatTitleString --> | ||
<<unusedtitle baseName:"base" template:"$count:2$-$basename$">> | ||
|
||
<<unusedtitle baseName:"" template:"$count:2$-$basename$">> | ||
|
||
<!-- UPPERCASES are intentional in template strings. They should be case-insensistive --> | ||
<<unusedtitle baseName:"asdf" separator:"-" template:"$coUNT:2$$sepaRATor$$baseName$">> | ||
|
||
<<unusedtitle baseName:"asdf" separator:"" template:"$count:2$$separator$$basename$">> | ||
|
||
+ | ||
title: ExpectedResult | ||
|
||
<p>New Tiddler</p><p>count-missing</p><p>00-new</p><p>00-base</p><p>00-New Tiddler</p><p>00-asdf</p><p>00 asdf</p> |