Skip to content

Commit 8bd9c09

Browse files
committed
test: Expand builder tests
1 parent 4406c1d commit 8bd9c09

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

ios/Tests/GutenbergKitTests/EditorConfigurationBuilderTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Foundation
12
import Testing
23
@testable import GutenbergKit
34

@@ -22,6 +23,8 @@ struct EditorConfigurationBuilderTests {
2223
#expect(builder.webViewGlobals == [])
2324
#expect(builder.editorSettings.isEmpty)
2425
#expect(builder.locale == "en")
26+
#expect(builder.editorAssetsEndpoint == nil)
27+
#expect(builder.cookies == [])
2528
}
2629

2730
@Test("Editor Configuration to Builder")
@@ -42,6 +45,8 @@ struct EditorConfigurationBuilderTests {
4245
.setWebViewGlobals([WebViewGlobal(name: "foo", value: .string("bar"))])
4346
.setEditorSettings(["foo":"bar"])
4447
.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: "/"])!])
4550
.build() // Convert to a configuration
4651
.toBuilder() // Then back to a builder (to test the configuration->builder logic)
4752
.build() // Then back to a configuration to examine the results
@@ -61,6 +66,8 @@ struct EditorConfigurationBuilderTests {
6166
#expect(configuration.webViewGlobals == [try WebViewGlobal(name: "foo", value: .string("bar"))])
6267
#expect(configuration.editorSettingsJSON == #"{"foo":"bar"}"#)
6368
#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: "/"])!])
6471
}
6572

6673
@Test("Sets Title Correctly")
@@ -160,4 +167,14 @@ struct EditorConfigurationBuilderTests {
160167
func editorConfigurationBuilderSetsLocaleCorrectly() throws {
161168
#expect(EditorConfigurationBuilder().setLocale("en").build().locale == "en")
162169
}
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+
}
163180
}

0 commit comments

Comments
 (0)