From b07ad42b49c0e3a24387af170d8ab2a4a0ed8226 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Wed, 17 Mar 2021 22:33:30 +0000 Subject: [PATCH] Started section spec tests --- .../HummingbirdMustacheTests/SpecTests.swift | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Tests/HummingbirdMustacheTests/SpecTests.swift b/Tests/HummingbirdMustacheTests/SpecTests.swift index 9157b68..9343e68 100644 --- a/Tests/HummingbirdMustacheTests/SpecTests.swift +++ b/Tests/HummingbirdMustacheTests/SpecTests.swift @@ -644,3 +644,31 @@ final class SpecPartialsTests: XCTestCase { try testPartial(object, template, ["partial": partial], expected) } } + +// MARK: Sections + +final class SpecSectionTests: XCTestCase { + func testTrue() throws { + let object = ["boolean": true] + let template = #""{{#boolean}}This should be rendered.{{/boolean}}""# + let expected = #""This should be rendered.""# + try test(object, template, expected) + + } + + func testFalse() throws { + let object = ["boolean": false] + let template = #""{{#boolean}}This should not be rendered.{{/boolean}}""# + let expected = "\"\"" + try test(object, template, expected) + + } + + func testContext() throws { + let object = ["context": ["name": "Joe"]] + let template = #""{{#context}}Hi {{name}}.{{/context}}""# + let expected = #""Hi Joe.""# + try test(object, template, expected) + + } +}