Skip to content

Commit

Permalink
Bring back all the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTim committed Nov 17, 2020
1 parent b8c7a4f commit 435f066
Showing 1 changed file with 26 additions and 42 deletions.
68 changes: 26 additions & 42 deletions Tests/LeafMarkdownTests/LeafTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,51 +36,35 @@ class MarkdownTests: XCTestCase {
func testRunTag() throws {
let inputMarkdown = "# This is a test\n\nWe have some text in a tag"
let expectedHtml = "<h1>This is a test</h1>\n<p>We have some text in a tag</p>\n"
let resultString = try render(context: ["data": .string(inputMarkdown)])
XCTAssertEqual(resultString, expectedHtml)
}

func testNilParameterDoesNotCrashLeaf() throws {
let expectedHtml = ""
let resultString = try render(context: ["data": .trueNil])
XCTAssertEqual(resultString, expectedHtml)
}

func testStripHtml() throws {
let inputMarkdown = "<br>"
let expectedHtml = "<!-- raw HTML omitted -->\n"

// let result = try renderer.render(path: template, context: ["data": .string(inputMarkdown)])
// let resultString = result.getString(at: 0, length: result.readableBytes)
let resultString = try render(context: ["data": .string(inputMarkdown)])
XCTAssertEqual(resultString, expectedHtml)
}

// func testNilParameterDoesNotCrashLeaf() throws {
// let expectedHtml = ""
// let result = try renderer.render(path: template, context: ["data": .nil])
// let resultString = result.getString(at: 0, length: result.readableBytes)
// XCTAssertEqual(resultString, expectedHtml)
// }
//
// func testStripHtml() throws {
// let inputMarkdown = "<br>"
// let expectedHtml = "<!-- raw HTML omitted -->\n"
//
// let result = try renderer.render(template, context: ["data": .string(inputMarkdown)])
// let resultString = result.getString(at: 0, length: result.readableBytes)
// XCTAssertEqual(resultString, expectedHtml)
// }
//
// func testRejectBadData() throws {
// let data = LeafData.lazy { .null }
// XCTAssertThrowsError(try renderer.render(template, context: ["data": data]))
// }
//
// func testDoNotStripHtml() throws {
// let loop = EmbeddedEventLoop()
// let config = LeafConfiguration(rootDirectory: Process().currentDirectoryPath)
// var tags = defaultTags
// tags["markdown"] = Markdown(options: [.unsafe])
// let renderer = LeafRenderer(
// configuration: config,
// tags: tags,
// files: NIOLeafFiles(fileio: .init(threadPool: .init(numberOfThreads: 1))),
// eventLoop: loop
// )
//
// let inputMarkdown = "<br>"
// let expectedHtml = "<br>\n"
//
// let result = try renderer.render(template, context: ["data": .string(inputMarkdown)])
// let resultString = result.getString(at: 0, length: result.readableBytes)
// XCTAssertEqual(resultString, expectedHtml)
// }
func testRejectBadData() throws {
XCTAssertThrowsError(try render(context: ["data": .dictionary(["something": .string("somethingelese")])]))
}

func testDoNotStripHtml() throws {
markdownTag = Markdown(options: [.unsafe])

let inputMarkdown = "<br>"
let expectedHtml = "<br>\n"

let resultString = try render(context: ["data": .string(inputMarkdown)])
XCTAssertEqual(resultString, expectedHtml)
}
}

0 comments on commit 435f066

Please sign in to comment.