-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #35
- Loading branch information
Showing
3 changed files
with
33 additions
and
16 deletions.
There are no files selected for viewing
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
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 @@ | ||
import Spectre | ||
import Stencil | ||
|
||
|
||
describe("ForNode") { | ||
let context = Context(dictionary: [ | ||
"items": [1, 2, 3], | ||
"emptyItems": [Int](), | ||
]) | ||
|
||
$0.it("renders the given nodes for each item") { | ||
let nodes: [NodeType] = [VariableNode(variable: "item")] | ||
let node = ForNode(variable: "items", loopVariable: "item", nodes: nodes, emptyNodes: []) | ||
try expect(try node.render(context)) == "123" | ||
} | ||
|
||
$0.it("renders the given empty nodes when no items found item") { | ||
let nodes: [NodeType] = [VariableNode(variable: "item")] | ||
let emptyNodes: [NodeType] = [TextNode(text: "empty")] | ||
let node = ForNode(variable: "emptyItems", loopVariable: "item", nodes: nodes, emptyNodes: emptyNodes) | ||
try expect(try node.render(context)) == "empty" | ||
} | ||
} |
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