@@ -60,25 +60,58 @@ final class RemoteBlogSettingsTests: XCTestCase {
60
60
// Rather than creating an object and checking the resulting NSDictionary,
61
61
// let's load one, convert it, then compare the source and converted dictionaries
62
62
let json = try loadJSONSettings ( )
63
- // FIXME: The init logic is currently in BlogServiceRemoteREST. We'll test it from there first, then update the test with the new location.
64
- let blogService = BlogServiceRemoteREST ( wordPressComRestApi: MockWordPressComRestApi ( ) , siteID: 0 )
65
- let settings = try XCTUnwrap ( blogService. remoteBlogSetting ( fromJSONDictionary: json) )
63
+ let settings = try XCTUnwrap ( RemoteBlogSettings ( jsonDictionary: json as NSDictionary ) )
66
64
67
- let dictionary = try XCTUnwrap ( blogService . remoteSettings ( toDictionary : settings) )
65
+ let dictionary = try XCTUnwrap ( settings. dictionaryRepresentation )
68
66
69
- // name and tagline have different keys when encoded...
70
- XCTAssertEqual ( dictionary [ " blogname " ] as? String , settings. name) // from JSON this is "name"
71
- XCTAssertEqual ( dictionary [ " blogdescription " ] as? String , settings. tagline) // from JSON this is "description"
72
- // Flattened settings properties
67
+ // defaultPostFormat has custom encoding, so let's test it explicitly.
68
+ // Note that here we're obviously testing only one of the possible paths.
69
+ XCTAssertEqual ( dictionary [ " default_post_format " ] as? String , settings. defaultPostFormat)
70
+
71
+ XCTAssertEqual ( dictionary [ " blogname " ] as? String , settings. name) // "name" in JSON
72
+ XCTAssertEqual ( dictionary [ " blogdescription " ] as? String , settings. tagline) // "description" in JSON
73
73
XCTAssertEqual ( dictionary [ " blog_public " ] as? NSNumber , settings. privacy)
74
74
XCTAssertEqual ( dictionary [ " lang_id " ] as? NSNumber , settings. languageID)
75
75
XCTAssertEqual ( dictionary [ " site_icon " ] as? NSNumber , settings. iconMediaID)
76
76
XCTAssertEqual ( dictionary [ " gmt_offset " ] as? NSNumber , settings. gmtOffset)
77
- // And so on...
77
+ XCTAssertEqual ( dictionary [ " timezone_string " ] as? String , settings. timezoneString)
78
+ XCTAssertEqual ( dictionary [ " default_category " ] as? NSNumber , settings. defaultCategoryID)
78
79
79
80
// defaultPostFormat has custom encoding, so let's test it explicitly.
80
81
// Note that here we're obviously testing only one of the possible paths.
81
82
XCTAssertEqual ( dictionary [ " default_post_format " ] as? String , settings. defaultPostFormat)
83
+
84
+ XCTAssertEqual ( dictionary [ " date_format " ] as? String , settings. dateFormat)
85
+ XCTAssertEqual ( dictionary [ " time_format " ] as? String , settings. timeFormat)
86
+ XCTAssertEqual ( dictionary [ " start_of_week " ] as? String , settings. startOfWeek)
87
+ XCTAssertEqual ( dictionary [ " posts_per_page " ] as? NSNumber , settings. postsPerPage)
88
+ XCTAssertEqual ( dictionary [ " default_comment_status " ] as? NSNumber , settings. commentsAllowed)
89
+ XCTAssertEqual ( dictionary [ " blacklist_keys " ] as? String , settings. commentsBlocklistKeys)
90
+ XCTAssertEqual ( dictionary [ " close_comments_for_old_posts " ] as? NSNumber , settings. commentsCloseAutomatically)
91
+ XCTAssertEqual ( dictionary [ " close_comments_days_old " ] as? NSNumber , settings. commentsCloseAutomaticallyAfterDays)
92
+ XCTAssertEqual ( dictionary [ " comment_whitelist " ] as? NSNumber , settings. commentsFromKnownUsersAllowlisted)
93
+ XCTAssertEqual ( dictionary [ " comment_max_links " ] as? NSNumber , settings. commentsMaximumLinks)
94
+ XCTAssertEqual ( dictionary [ " moderation_keys " ] as? String , settings. commentsModerationKeys)
95
+ XCTAssertEqual ( dictionary [ " page_comments " ] as? NSNumber , settings. commentsPagingEnabled)
96
+ XCTAssertEqual ( dictionary [ " comments_per_page " ] as? NSNumber , settings. commentsPageSize)
97
+ XCTAssertEqual ( dictionary [ " comment_moderation " ] as? NSNumber , settings. commentsRequireManualModeration)
98
+ XCTAssertEqual ( dictionary [ " require_name_email " ] as? NSNumber , settings. commentsRequireNameAndEmail)
99
+ XCTAssertEqual ( dictionary [ " comment_registration " ] as? NSNumber , settings. commentsRequireRegistration)
100
+ XCTAssertEqual ( dictionary [ " comment_order " ] as? String , settings. commentsSortOrder)
101
+ XCTAssertEqual ( dictionary [ " thread_comments " ] as? NSNumber , settings. commentsThreadingEnabled)
102
+ XCTAssertEqual ( dictionary [ " thread_comments_depth " ] as? NSNumber , settings. commentsThreadingDepth)
103
+ XCTAssertEqual ( dictionary [ " jetpack_relatedposts_allowed " ] as? NSNumber , settings. relatedPostsAllowed)
104
+ XCTAssertEqual ( dictionary [ " jetpack_relatedposts_enabled " ] as? NSNumber , settings. relatedPostsEnabled)
105
+ XCTAssertEqual ( dictionary [ " jetpack_relatedposts_show_headline " ] as? NSNumber , settings. relatedPostsShowHeadline)
106
+ XCTAssertEqual ( dictionary [ " jetpack_relatedposts_show_thumbnails " ] as? NSNumber , settings. relatedPostsShowThumbnails)
107
+ XCTAssertEqual ( dictionary [ " amp_is_supported " ] as? NSNumber , settings. ampSupported)
108
+ XCTAssertEqual ( dictionary [ " amp_is_enabled " ] as? NSNumber , settings. ampEnabled)
109
+ XCTAssertEqual ( dictionary [ " sharing_button_style " ] as? String , settings. sharingButtonStyle)
110
+ XCTAssertEqual ( dictionary [ " sharing_label " ] as? String , settings. sharingLabel)
111
+ XCTAssertEqual ( dictionary [ " twitter_via " ] as? String , settings. sharingTwitterName)
112
+ XCTAssertEqual ( dictionary [ " jetpack_comment_likes_enabled " ] as? NSNumber , settings. sharingCommentLikesEnabled)
113
+ XCTAssertEqual ( dictionary [ " disabled_likes " ] as? NSNumber , settings. sharingDisabledLikes)
114
+ XCTAssertEqual ( dictionary [ " disabled_reblogs " ] as? NSNumber , settings. sharingDisabledReblogs)
82
115
}
83
116
84
117
func loadJSONSettings( ) throws -> [ String : Any ] {
0 commit comments