Skip to content

Commit cee22f3

Browse files
added some basic unit tests
1 parent d66f5b1 commit cee22f3

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.10
1+
// swift-tools-version:5.10
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription

Sources/HTMLKitMacros/HTMLKitMacros.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@ struct ErrorDiagnostic : DiagnosticMessage {
1919
self.message = message
2020
self.diagnosticID = MessageID(domain: "HTMLKitMacros", id: id)
2121
}
22-
23-
static let notAStruct:ErrorDiagnostic = ErrorDiagnostic(id: "notAStruct", message: "Can only be applied to a 'struct'")
24-
static let notAnEnum:ErrorDiagnostic = ErrorDiagnostic(id: "notAnEnum", message: "Can only be aplpied to an 'enum")
25-
static let notAnExtension:ErrorDiagnostic = ErrorDiagnostic(id: "notAnExtension", message: "Can only be applied to an 'extension'")
26-
27-
static let noArguments:ErrorDiagnostic = ErrorDiagnostic(id: "noArguments", message: "No arguments")
28-
29-
static func missingParameter(_ key: String) -> ErrorDiagnostic {
30-
return ErrorDiagnostic(id: "missingParameter", message: "Missing \"" + key + "\" parameter")
31-
}
3222
}
3323

3424
@main

Tests/HTMLKitTests/HTMLKitTests.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ import XCTest
1010

1111
final class HTMLKitTests : XCTestCase {
1212
func testExample() throws {
13+
}
14+
}
15+
16+
extension HTMLKitTests {
17+
func test_macro_html() {
18+
XCTAssertEqual(#html(innerHTML: []), "<!DOCTYPE html><html></html>")
19+
XCTAssertEqual(#html(xmlns: "test", innerHTML: []), "<!DOCTYPE html><html xmlns=\"test\"></html>")
20+
}
21+
}
22+
23+
extension HTMLKitTests {
24+
func test_example1() {
1325
let test:String = #html(innerHTML: [
1426
#body(innerHTML: [
1527
#div(
@@ -31,6 +43,6 @@ final class HTMLKitTests : XCTestCase {
3143
)
3244
])
3345
])
34-
print("test=" + test)
46+
XCTAssertEqual(test, "<!DOCTYPE html><html><body><div class=\"bing bong\" title=\"just seeing what blow's\" draggable=\"false\" inputmode=\"email\" hidden=\"hidden\">poggies<div></div><a><div><abbr></abbr></div><address></address></a><div></div><button disabled></button><video autoplay preload=\"auto\" src=\"ezclap\" width=\"5\"></video></div></body></html>")
3547
}
36-
}
48+
}

0 commit comments

Comments
 (0)