Skip to content

Commit 38a57fc

Browse files
committed
extend macro tests
1 parent 0c44bca commit 38a57fc

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

Components/Macro/Tests/MutableMacroTests.swift

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ let testMacros: [String: Macro.Type] = [
99

1010
final class MutableMacroTests: XCTestCase {
1111

12-
func testMutableMacro_expansion() {
12+
func testExpansionSucceded_whenAppliedToStruct_withVariablesAndType() {
1313
assertMacroExpansion(
1414
"""
1515
@Mutable
1616
struct SomeStruct {
17-
let id: String = ""
18-
var someVar: Bool = false
17+
let id: String = ""
18+
var someVar: Bool = false
1919
}
2020
""",
2121
expandedSource: """
@@ -33,8 +33,44 @@ final class MutableMacroTests: XCTestCase {
3333
)
3434
}
3535

36-
func testMutableMacro_application() {
37-
// TODO: - check that macro throwing error
36+
func testExpansionFailed_whenAppliedTo_nonStruct() {
37+
assertMacroExpansion(
38+
"""
39+
@Mutable
40+
class SomeStruct {
41+
let id: String = ""
42+
var someVar: Bool = false
43+
}
44+
""",
45+
expandedSource: """
46+
@Mutable
47+
class SomeStruct {
48+
let id: String = ""
49+
var someVar: Bool = false
50+
}
51+
""",
52+
macros: testMacros
53+
)
54+
}
55+
56+
func testExpansionFailed_whenAppliedTo_variableWithoutAnnotation() {
57+
assertMacroExpansion(
58+
"""
59+
@Mutable
60+
struct SomeStruct {
61+
let id: String = ""
62+
var someVar = false
63+
}
64+
""",
65+
expandedSource: """
66+
@Mutable
67+
struct SomeStruct {
68+
let id: String = ""
69+
var someVar = false
70+
}
71+
""",
72+
macros: testMacros
73+
)
3874
}
3975

4076
}

0 commit comments

Comments
 (0)