Skip to content

Commit 387a766

Browse files
committed
Unwrap optionals for plugins in SitePluginMapperTests
1 parent 7cb4895 commit 387a766

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

Networking/NetworkingTests/Mapper/SitePluginMapperTests.swift

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,38 @@ final class SitePluginMapperTests: XCTestCase {
1111

1212
/// Verifies the SitePlugin fields are parsed correctly.
1313
///
14-
func test_SitePlugin_fields_are_properly_parsed() {
15-
let plugin = mapPlugin(from: "plugin")
16-
XCTAssertNotNil(plugin)
17-
XCTAssertEqual(plugin?.plugin, "jetpack/jetpack")
18-
XCTAssertEqual(plugin?.siteID, dummySiteID)
19-
XCTAssertEqual(plugin?.status, .active)
20-
XCTAssertEqual(plugin?.name, "Jetpack by WordPress.com")
21-
XCTAssertEqual(plugin?.pluginUri, "https://jetpack.com")
22-
XCTAssertEqual(plugin?.author, "Automattic")
23-
XCTAssertEqual(plugin?.descriptionRaw, "Bring the power of the WordPress.com cloud to your self-hosted WordPress.")
24-
XCTAssertEqual(plugin?.descriptionRendered, "Bring the power of the WordPress.com cloud to your self-hosted WordPress. " +
14+
func test_SitePlugin_fields_are_properly_parsed() throws {
15+
let plugin = try XCTUnwrap(mapPlugin(from: "plugin"))
16+
XCTAssertEqual(plugin.plugin, "jetpack/jetpack")
17+
XCTAssertEqual(plugin.siteID, dummySiteID)
18+
XCTAssertEqual(plugin.status, .active)
19+
XCTAssertEqual(plugin.name, "Jetpack by WordPress.com")
20+
XCTAssertEqual(plugin.pluginUri, "https://jetpack.com")
21+
XCTAssertEqual(plugin.author, "Automattic")
22+
XCTAssertEqual(plugin.descriptionRaw, "Bring the power of the WordPress.com cloud to your self-hosted WordPress.")
23+
XCTAssertEqual(plugin.descriptionRendered, "Bring the power of the WordPress.com cloud to your self-hosted WordPress. " +
2524
"<cite>By <a href=\"https://jetpack.com\">Automattic</a>.</cite>")
26-
XCTAssertEqual(plugin?.version, "9.5")
27-
XCTAssertEqual(plugin?.textDomain, "jetpack")
25+
XCTAssertEqual(plugin.version, "9.5")
26+
XCTAssertEqual(plugin.textDomain, "jetpack")
2827
}
2928

3029
/// Verifies the SitePlugin fields are parsed correctly when there's no data envelope wrapping the response.
3130
///
32-
func test_SitePlugin_fields_are_properly_parsed_for_response_without_data_envelope() {
33-
let plugin = mapPluginWithoutEnvelope(from: "site-plugin-without-envelope")
34-
XCTAssertNotNil(plugin)
35-
XCTAssertEqual(plugin?.plugin, "jetpack/jetpack")
36-
XCTAssertEqual(plugin?.siteID, -1)
37-
XCTAssertEqual(plugin?.status, .active)
38-
XCTAssertEqual(plugin?.name, "Jetpack")
39-
XCTAssertEqual(plugin?.pluginUri, "https://jetpack.com")
40-
XCTAssertEqual(plugin?.author, "Automattic")
41-
XCTAssertEqual(plugin?.descriptionRaw, "Security, performance, and marketing tools made by WordPress experts. " +
31+
func test_SitePlugin_fields_are_properly_parsed_for_response_without_data_envelope() throws {
32+
let plugin = try XCTUnwrap(mapPluginWithoutEnvelope(from: "site-plugin-without-envelope"))
33+
XCTAssertEqual(plugin.plugin, "jetpack/jetpack")
34+
XCTAssertEqual(plugin.siteID, -1)
35+
XCTAssertEqual(plugin.status, .active)
36+
XCTAssertEqual(plugin.name, "Jetpack")
37+
XCTAssertEqual(plugin.pluginUri, "https://jetpack.com")
38+
XCTAssertEqual(plugin.author, "Automattic")
39+
XCTAssertEqual(plugin.descriptionRaw, "Security, performance, and marketing tools made by WordPress experts. " +
4240
"Jetpack keeps your site protected so you can focus on more important things.")
43-
XCTAssertEqual(plugin?.descriptionRendered, "Security, performance, and marketing tools made by WordPress experts. " +
41+
XCTAssertEqual(plugin.descriptionRendered, "Security, performance, and marketing tools made by WordPress experts. " +
4442
"Jetpack keeps your site protected so you can focus on more important things. " +
4543
"<cite>By <a href=\"https://jetpack.com\">Automattic</a>.</cite>")
46-
XCTAssertEqual(plugin?.version, "11.5.1")
47-
XCTAssertEqual(plugin?.textDomain, "jetpack")
44+
XCTAssertEqual(plugin.version, "11.5.1")
45+
XCTAssertEqual(plugin.textDomain, "jetpack")
4846
}
4947
}
5048

0 commit comments

Comments
 (0)