@@ -9,59 +9,59 @@ struct EditorSettingsTests {
99 // MARK: - themeStyles Tests
1010
1111 @Test ( " themeStyles is empty when styles array is empty " )
12- func themeStylesEmptyWhenNoStyles( ) {
12+ func themeStylesEmptyWhenNoStyles( ) throws {
1313 let json = #"{"styles": []}"#
14- let settings = EditorSettings ( data: Data ( json. utf8) )
14+ let settings = try EditorSettings ( data: Data ( json. utf8) )
1515 #expect( settings. themeStyles. isEmpty)
1616 }
1717
1818 @Test ( " themeStyles extracts single css value " )
19- func themeStylesExtractsSingleCSS( ) {
19+ func themeStylesExtractsSingleCSS( ) throws {
2020 let json = #"{"styles": [{"css": "body { color: red; }", "isGlobalStyles": true}]}"#
21- let settings = EditorSettings ( data: Data ( json. utf8) )
21+ let settings = try EditorSettings ( data: Data ( json. utf8) )
2222 #expect( settings. themeStyles == " body { color: red; } " )
2323 }
2424
2525 @Test ( " themeStyles joins multiple css values with newlines " )
26- func themeStylesJoinsMultipleCSS( ) {
26+ func themeStylesJoinsMultipleCSS( ) throws {
2727 let json = """
2828 { " styles " : [{ " css " : " body { color: red; } " , " isGlobalStyles " : true}, { " css " : " h1 { font-size: 2em; } " , " isGlobalStyles " : false}]}
2929 """
30- let settings = EditorSettings ( data: Data ( json. utf8) )
30+ let settings = try EditorSettings ( data: Data ( json. utf8) )
3131 #expect( settings. themeStyles == " body { color: red; } \n h1 { font-size: 2em; } " )
3232 }
3333
3434 @Test ( " themeStyles skips styles with null css " )
35- func themeStylesSkipsNullCSS( ) {
35+ func themeStylesSkipsNullCSS( ) throws {
3636 let json = """
3737 { " styles " : [{ " css " : null, " isGlobalStyles " : true}, { " css " : " h1 { font-size: 2em; } " , " isGlobalStyles " : false}]}
3838 """
39- let settings = EditorSettings ( data: Data ( json. utf8) )
39+ let settings = try EditorSettings ( data: Data ( json. utf8) )
4040 #expect( settings. themeStyles == " h1 { font-size: 2em; } " )
4141 }
4242
4343 @Test ( " themeStyles skips styles without css key " )
44- func themeStylesSkipsMissingCSS( ) {
44+ func themeStylesSkipsMissingCSS( ) throws {
4545 let json = """
4646 { " styles " : [{ " isGlobalStyles " : true}, { " css " : " h1 { font-size: 2em; } " , " isGlobalStyles " : false}]}
4747 """
48- let settings = EditorSettings ( data: Data ( json. utf8) )
48+ let settings = try EditorSettings ( data: Data ( json. utf8) )
4949 #expect( settings. themeStyles == " h1 { font-size: 2em; } " )
5050 }
5151
5252 @Test ( " themeStyles is empty when JSON is invalid " )
53- func themeStylesEmptyForInvalidJSON( ) {
53+ func themeStylesEmptyForInvalidJSON( ) throws {
5454 let invalidJSON = " not valid json "
55- let settings = EditorSettings ( data: Data ( invalidJSON. utf8) )
55+ let settings = try EditorSettings ( data: Data ( invalidJSON. utf8) )
5656 #expect( settings. themeStyles. isEmpty)
5757 }
5858
5959 @Test ( " themeStyles is empty when styles key is missing " )
60- func themeStylesEmptyWhenStylesKeyMissing( ) {
60+ func themeStylesEmptyWhenStylesKeyMissing( ) throws {
6161 let json = """
6262 { " otherKey " : " value " }
6363 """
64- let settings = EditorSettings ( data: Data ( json. utf8) )
64+ let settings = try EditorSettings ( data: Data ( json. utf8) )
6565 #expect( settings. themeStyles. isEmpty)
6666 }
6767
@@ -72,7 +72,7 @@ struct EditorSettingsTests {
7272 let json = """
7373 { " styles " : [{ " css " : " body { color: red; } " , " isGlobalStyles " : true}]}
7474 """
75- let original = EditorSettings ( data: Data ( json. utf8) )
75+ let original = try EditorSettings ( data: Data ( json. utf8) )
7676
7777 let encoded = try JSONEncoder ( ) . encode ( original)
7878 let decoded = try JSONDecoder ( ) . decode ( EditorSettings . self, from: encoded)
@@ -86,7 +86,7 @@ struct EditorSettingsTests {
8686 let json = """
8787 { " styles " : [{ " css " : " .theme-class { background: blue; } " , " isGlobalStyles " : true}, { " css " : " .another { margin: 10px; } " , " isGlobalStyles " : false}]}
8888 """
89- let original = EditorSettings ( data: Data ( json. utf8) )
89+ let original = try EditorSettings ( data: Data ( json. utf8) )
9090
9191 let encoded = try JSONEncoder ( ) . encode ( original)
9292 let decoded = try JSONDecoder ( ) . decode ( EditorSettings . self, from: encoded)
@@ -97,29 +97,29 @@ struct EditorSettingsTests {
9797 // MARK: - Edge Cases
9898
9999 @Test ( " themeStyles handles empty css string " )
100- func themeStylesHandlesEmptyCSS( ) {
100+ func themeStylesHandlesEmptyCSS( ) throws {
101101 let json = """
102102 { " styles " : [{ " css " : " " , " isGlobalStyles " : true}]}
103103 """
104- let settings = EditorSettings ( data: Data ( json. utf8) )
104+ let settings = try EditorSettings ( data: Data ( json. utf8) )
105105 #expect( settings. themeStyles == " " )
106106 }
107107
108108 @Test ( " themeStyles handles css with special characters " )
109- func themeStylesHandlesSpecialCharacters( ) {
109+ func themeStylesHandlesSpecialCharacters( ) throws {
110110 let json = """
111111 { " styles " : [{ " css " : " .class::before { content: ' \\ u003C'; } " , " isGlobalStyles " : true}]}
112112 """
113- let settings = EditorSettings ( data: Data ( json. utf8) )
113+ let settings = try EditorSettings ( data: Data ( json. utf8) )
114114 #expect( settings. themeStyles. contains ( " ::before " ) )
115115 }
116116
117117 @Test ( " themeStyles handles multiline css " )
118- func themeStylesHandlesMultilineCSS( ) {
118+ func themeStylesHandlesMultilineCSS( ) throws {
119119 let json = """
120120 { " styles " : [{ " css " : " body { \\ n color: red; \\ n background: blue; \\ n} " , " isGlobalStyles " : true}]}
121121 """
122- let settings = EditorSettings ( data: Data ( json. utf8) )
122+ let settings = try EditorSettings ( data: Data ( json. utf8) )
123123 #expect( settings. themeStyles. contains ( " color: red " ) )
124124 #expect( settings. themeStyles. contains ( " background: blue " ) )
125125 }
0 commit comments