Skip to content

Commit a12d51d

Browse files
committed
Change static function on JSONObject to an initialiser
1 parent a0947c7 commit a12d51d

12 files changed

+34
-35
lines changed

WordPress/WordPressTest/ActivityContentFactoryTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final class ActivityContentFactoryTests: XCTestCase {
1111
}
1212

1313
private func mockBlock() throws -> JSONObject {
14-
return try .loadJSONFile(named: "activity-log-activity-content.json")
14+
return try JSONObject(fromFileNamed: "activity-log-activity-content.json")
1515
}
1616

1717
}

WordPress/WordPressTest/ActivityLogTestData.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,39 +28,39 @@ class ActivityLogTestData {
2828
}
2929

3030
func getCommentEventDictionary() throws -> JSONObject {
31-
return try .loadJSONFile(named: "activity-log-comment.json")
31+
return try JSONObject(fromFileNamed: "activity-log-comment.json")
3232
}
3333

3434
func getPostEventDictionary() throws -> JSONObject {
35-
return try .loadJSONFile(named: "activity-log-post.json")
35+
return try JSONObject(fromFileNamed: "activity-log-post.json")
3636
}
3737

3838
func getPingbackDictionary() throws -> JSONObject {
39-
return try .loadJSONFile(named: "activity-log-pingback-content.json")
39+
return try JSONObject(fromFileNamed: "activity-log-pingback-content.json")
4040
}
4141

4242
func getPostContentDictionary() throws -> JSONObject {
43-
return try .loadJSONFile(named: "activity-log-post-content.json")
43+
return try JSONObject(fromFileNamed: "activity-log-post-content.json")
4444
}
4545

4646
func getCommentContentDictionary() throws -> JSONObject {
47-
return try .loadJSONFile(named: "activity-log-comment-content.json")
47+
return try JSONObject(fromFileNamed: "activity-log-comment-content.json")
4848
}
4949

5050
func getThemeContentDictionary() throws -> JSONObject {
51-
return try .loadJSONFile(named: "activity-log-theme-content.json")
51+
return try JSONObject(fromFileNamed: "activity-log-theme-content.json")
5252
}
5353

5454
func getSettingsContentDictionary() throws -> JSONObject {
55-
return try .loadJSONFile(named: "activity-log-settings-content.json")
55+
return try JSONObject(fromFileNamed: "activity-log-settings-content.json")
5656
}
5757

5858
func getSiteContentDictionary() throws -> JSONObject {
59-
return try .loadJSONFile(named: "activity-log-site-content.json")
59+
return try JSONObject(fromFileNamed: "activity-log-site-content.json")
6060
}
6161

6262
func getPluginContentDictionary() throws -> JSONObject {
63-
return try .loadJSONFile(named: "activity-log-plugin-content.json")
63+
return try JSONObject(fromFileNamed: "activity-log-plugin-content.json")
6464
}
6565

6666
func getCommentRangeDictionary() throws -> JSONObject {

WordPress/WordPressTest/FormattableCommentContentTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ final class FormattableCommentContentTests: XCTestCase {
134134
}
135135

136136
private func mockDictionary() throws -> JSONObject {
137-
return try .loadJSONFile(named: "notifications-comment-content.json")
137+
return try JSONObject(fromFileNamed: "notifications-comment-content.json")
138138
}
139139

140140
private func loadLikeNotification() throws -> WordPress.Notification {
141141
return try utility.loadLikeNotification()
142142
}
143143

144144
private func loadMeta() throws -> JSONObject {
145-
return try .loadJSONFile(named: "notifications-comment-meta.json")
145+
return try JSONObject(fromFileNamed: "notifications-comment-meta.json")
146146
}
147147

148148
private func mockedActions() -> [FormattableContentAction] {

WordPress/WordPressTest/FormattableContentGroupTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ final class FormattableContentGroupTests: XCTestCase {
6060
}
6161

6262
private func mockActivity() throws -> JSONObject {
63-
return try .loadJSONFile(named: "activity-log-activity-content.json")
63+
return try JSONObject(fromFileNamed: "activity-log-activity-content.json")
6464
}
6565

6666
}

WordPress/WordPressTest/FormattableUserContentTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ final class FormattableUserContentTests: XCTestCase {
130130
}
131131

132132
private func mockDictionary() throws -> JSONObject {
133-
return try .loadJSONFile(named: "notifications-user-content.json")
133+
return try JSONObject(fromFileNamed: "notifications-user-content.json")
134134
}
135135

136136
private func loadLikeNotification() throws -> WordPress.Notification {
137137
return try .fixture(fromFile: "notifications-like.json", insertInto: contextManager.mainContext)
138138
}
139139

140140
private func loadMeta() throws -> JSONObject {
141-
return try .loadJSONFile(named: "notifications-user-content-meta.json")
141+
return try JSONObject(fromFileNamed: "notifications-user-content-meta.json")
142142
}
143143

144144
private func mockedActions() -> [FormattableContentAction] {

WordPress/WordPressTest/NSManagedObject+Fixture.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extension NSManagedObject {
99
/// - context: The managed object context to use
1010
/// - Returns: A new instance with property values of the given JSON file.
1111
static func fixture(fromFile fileName: String, insertInto context: NSManagedObjectContext) throws -> Self {
12-
let jsonObject = try JSONObject.loadJSONFile(named: fileName)
12+
let jsonObject = try JSONObject(fromFileNamed: fileName)
1313
let model = Self.init(context: context)
1414
for (key, value) in jsonObject {
1515
model.setValue(value, forKey: key)

WordPress/WordPressTest/NotificationContentRangeFactoryTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,27 @@ final class NotificationContentRangeFactoryTests: XCTestCase {
4141
}
4242

4343
private func mockCommentRange() throws -> JSONObject {
44-
return try .loadJSONFile(named: "notifications-comment-range.json")
44+
return try JSONObject(fromFileNamed: "notifications-comment-range.json")
4545
}
4646

4747
private func mockIconRange() throws -> JSONObject {
48-
return try .loadJSONFile(named: "notifications-icon-range.json")
48+
return try JSONObject(fromFileNamed: "notifications-icon-range.json")
4949
}
5050

5151
private func mockPostRange() throws -> JSONObject {
52-
return try .loadJSONFile(named: "notifications-post-range.json")
52+
return try JSONObject(fromFileNamed: "notifications-post-range.json")
5353
}
5454

5555
private func mockSiteRange() throws -> JSONObject {
56-
return try .loadJSONFile(named: "notifications-site-range.json")
56+
return try JSONObject(fromFileNamed: "notifications-site-range.json")
5757
}
5858

5959
private func mockUserRange() throws -> JSONObject {
60-
return try .loadJSONFile(named: "notifications-user-range.json")
60+
return try JSONObject(fromFileNamed: "notifications-user-range.json")
6161
}
6262

6363
private func mockBlockQuoteRange() throws -> JSONObject {
64-
return try .loadJSONFile(named: "notifications-blockquote-range.json")
64+
return try JSONObject(fromFileNamed: "notifications-blockquote-range.json")
6565
}
6666

6767
}

WordPress/WordPressTest/NotificationTextContentTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ final class NotificationTextContentTests: XCTestCase {
8888
}
8989

9090
private func mockDictionary() throws -> JSONObject {
91-
return try .loadJSONFile(named: "notifications-text-content.json")
91+
return try JSONObject(fromFileNamed: "notifications-text-content.json")
9292
}
9393

9494
private func mockButtonContentDictionary() throws -> JSONObject {
95-
return try .loadJSONFile(named: "notifications-button-text-content.json")
95+
return try JSONObject(fromFileNamed: "notifications-button-text-content.json")
9696
}
9797

9898
private func loadLikeNotification() throws -> WordPress.Notification {

WordPress/WordPressTest/NotificationUtility.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class NotificationUtility {
4545
}
4646

4747
func mockCommentContent() throws -> FormattableCommentContent {
48-
let dictionary = try JSONObject.loadJSONFile(named: "notifications-replied-comment.json")
48+
let dictionary = try JSONObject(fromFileNamed: "notifications-replied-comment.json")
4949
let body = dictionary["body"]
5050
let blocks = NotificationContentFactory.content(from: body as! [[String: AnyObject]], actionsParser: NotificationActionParser(), parent: WordPress.Notification(context: contextManager.mainContext))
5151
return blocks.filter { $0.kind == .comment }.first! as! FormattableCommentContent

WordPress/WordPressTest/NotificationsContentFactoryTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ final class NotificationsContentFactoryTests: XCTestCase {
2424
}
2525

2626
private func mockTextContentDictionary() throws -> JSONObject {
27-
return try .loadJSONFile(named: "notifications-text-content.json")
27+
return try JSONObject(fromFileNamed: "notifications-text-content.json")
2828
}
2929

3030
private func mockCommentContentDictionary() throws -> JSONObject {
31-
return try .loadJSONFile(named: "notifications-comment-content.json")
31+
return try JSONObject(fromFileNamed: "notifications-comment-content.json")
3232
}
3333

3434
private func mockUserContentDictionary() throws -> JSONObject {
35-
return try .loadJSONFile(named: "notifications-user-content.json")
35+
return try JSONObject(fromFileNamed: "notifications-user-content.json")
3636
}
3737

3838
func loadLikeNotification() throws -> WordPress.Notification {

0 commit comments

Comments
 (0)