Files
swiftpm-mustache/Tests/HummingbirdMustacheTests/LibraryTests.swift
Adam Fowler aa30dcbddf Don't log files that dont load throw error instead
remove swift-log dependency
2021-03-18 15:25:46 +00:00

19 lines
867 B
Swift

@testable import HummingbirdMustache
import XCTest
final class LibraryTests: XCTestCase {
func testDirectoryLoad() throws {
let fs = FileManager()
try? fs.createDirectory(atPath: "templates", withIntermediateDirectories: false)
let mustache = "<test>{{#value}}<value>{{.}}</value>{{/value}}</test>"
let data = Data(mustache.utf8)
defer { XCTAssertNoThrow(try fs.removeItem(atPath: "templates")) }
try data.write(to: URL(fileURLWithPath: "templates/test.mustache"))
defer { XCTAssertNoThrow(try fs.removeItem(atPath: "templates/test.mustache")) }
let library = try HBMustacheLibrary(directory: "./templates")
let object = ["value": ["value1", "value2"]]
XCTAssertEqual(library.render(object, withTemplate: "test"), "<test><value>value1</value><value>value2</value></test>")
}
}