1
+ import Foundation
1
2
import Testing
2
3
@testable import GutenbergKit
3
4
@@ -22,6 +23,8 @@ struct EditorConfigurationBuilderTests {
22
23
#expect( builder. webViewGlobals == [ ] )
23
24
#expect( builder. editorSettings. isEmpty)
24
25
#expect( builder. locale == " en " )
26
+ #expect( builder. editorAssetsEndpoint == nil )
27
+ #expect( builder. cookies == [ ] )
25
28
}
26
29
27
30
@Test ( " Editor Configuration to Builder " )
@@ -42,6 +45,8 @@ struct EditorConfigurationBuilderTests {
42
45
. setWebViewGlobals ( [ WebViewGlobal ( name: " foo " , value: . string( " bar " ) ) ] )
43
46
. setEditorSettings ( [ " foo " : " bar " ] )
44
47
. setLocale ( " fr " )
48
+ . setEditorAssetsEndpoint ( URL ( string: " https://example.com/wp-content/plugins/gutenberg/build/ " ) )
49
+ . setCookies ( [ HTTPCookie ( properties: [ . name: " foo " , . value: " bar " , . domain: " example.com " , . path: " / " ] ) !] )
45
50
. build ( ) // Convert to a configuration
46
51
. toBuilder ( ) // Then back to a builder (to test the configuration->builder logic)
47
52
. build ( ) // Then back to a configuration to examine the results
@@ -61,6 +66,8 @@ struct EditorConfigurationBuilderTests {
61
66
#expect( configuration. webViewGlobals == [ try WebViewGlobal ( name: " foo " , value: . string( " bar " ) ) ] )
62
67
#expect( configuration. editorSettingsJSON == #"{"foo":"bar"}"# )
63
68
#expect( configuration. locale == " fr " )
69
+ #expect( configuration. editorAssetsEndpoint == URL ( string: " https://example.com/wp-content/plugins/gutenberg/build/ " ) )
70
+ #expect( configuration. cookies == [ HTTPCookie ( properties: [ . name: " foo " , . value: " bar " , . domain: " example.com " , . path: " / " ] ) !] )
64
71
}
65
72
66
73
@Test ( " Sets Title Correctly " )
@@ -160,4 +167,14 @@ struct EditorConfigurationBuilderTests {
160
167
func editorConfigurationBuilderSetsLocaleCorrectly( ) throws {
161
168
#expect( EditorConfigurationBuilder ( ) . setLocale ( " en " ) . build ( ) . locale == " en " )
162
169
}
170
+
171
+ @Test ( " Sets editorAssetsEndpoint Correctly " )
172
+ func editorConfigurationBuilderSetsEditorAssetsEndpointCorrectly( ) throws {
173
+ #expect( EditorConfigurationBuilder ( ) . setEditorAssetsEndpoint ( URL ( string: " https://example.com/wp-content/plugins/gutenberg/build/ " ) ) . build ( ) . editorAssetsEndpoint == URL ( string: " https://example.com/wp-content/plugins/gutenberg/build/ " ) )
174
+ }
175
+
176
+ @Test ( " Sets cookies Correctly " )
177
+ func editorConfigurationBuilderSetsCookiesCorrectly( ) throws {
178
+ #expect( EditorConfigurationBuilder ( ) . setCookies ( [ HTTPCookie ( properties: [ . name: " foo " , . value: " bar " , . domain: " example.com " , . path: " / " ] ) !] ) . build ( ) . cookies == [ HTTPCookie ( properties: [ . name: " foo " , . value: " bar " , . domain: " example.com " , . path: " / " ] ) !] )
179
+ }
163
180
}
0 commit comments