Skip to content

Commit e3fa92b

Browse files
authored
chore(tests): update home test fixtures (#679)
1 parent 24de4d6 commit e3fa92b

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

Tests iOS/Fixtures/save-recommendation-1.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
{
22
"data": {
33
"upsertSavedItem": {
4-
"__typename": "[type-name-here]",
5-
"remoteID": "slate-1-rec-1-saved-item",
6-
"url": "https://example.com/item-1",
4+
"__typename": "SavedItem",
5+
"remoteID": "slate-1-rec-1",
6+
"url": "http://localhost:8080/slate-1-rec-1",
77
"_createdAt": 1,
88
"_deletedAt": null,
99
"archivedAt": null,
1010
"isArchived": false,
1111
"isFavorite": false,
1212
"tags": [],
1313
"item": {
14-
"__typename": "[some-type-name]",
15-
"remoteID": "recommended-item-1",
16-
"givenUrl": "https://example.com/item-1",
17-
"resolvedUrl": "https://example.com/item-1",
14+
"__typename": "Item",
15+
"remoteID": "slate-1-rec-1",
16+
"givenUrl": "http://localhost:8080/slate-1-rec-1",
17+
"resolvedUrl": "http://localhost:8080/slate-1-rec-1",
1818
"title": "Slate 1, Recommendation 1",
1919
"language": "en",
2020
"topImageUrl": "http://example.com/slate-1-rec-1/top-image.png",
2121
"timeToRead": 1,
22+
"wordCount": 200,
2223
"marticle": [],
2324
"authors": [
2425
{

Tests iOS/Fixtures/save-recommendation-2.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
{
22
"data": {
33
"upsertSavedItem": {
4-
"__typename": "[type-name-here]",
5-
"remoteID": "slate-1-rec-2-saved-item",
6-
"url": "https://example.com/item-2",
4+
"__typename": "SavedItem",
5+
"remoteID": "slate-1-rec-2",
6+
"url": "https://example.com/slate-1-rec-2",
77
"_createdAt": 1,
88
"_deletedAt": null,
99
"archivedAt": null,
1010
"isArchived": false,
1111
"isFavorite": false,
1212
"tags": [],
1313
"item": {
14-
"__typename": "[some-type-name]",
15-
"remoteID": "recommended-item-2",
16-
"givenUrl": "https://example.com/item-2",
17-
"resolvedUrl": "https://example.com/item-2",
14+
"__typename": "Item",
15+
"remoteID": "slate-1-rec-2",
16+
"givenUrl": "https://example.com/slate-1-rec-2",
17+
"resolvedUrl": "https://example.com/slate-1-rec-2",
1818
"title": "Slate 1, Recommendation 2",
1919
"language": "en",
2020
"topImageUrl": "http://example.com/slate-1-rec-2/top-image.png",
2121
"timeToRead": 2,
22+
"wordCount": 200,
2223
"marticle": [],
2324
"authors": [],
2425
"datePublished": "2021-01-01 12:01:01",

Tests iOS/Fixtures/slates.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"curatedInfo": null,
2121
"item": {
2222
"__typename": "[some-type-name]",
23-
"remoteID": "recommended-item-1",
23+
"remoteID": "slate-1-rec-1",
2424
"givenUrl": "http://localhost:8080/slate-1-rec-1",
2525
"resolvedUrl": "http://localhost:8080/slate-1-rec-1",
2626
"title": "Slate 1, Recommendation 1",
@@ -65,7 +65,7 @@
6565
"curatedInfo": null,
6666
"item": {
6767
"__typename": "[some-type-name]",
68-
"remoteID": "recommended-item-2",
68+
"remoteID": "slate-1-rec-2",
6969
"givenUrl": "https://example.com/slate-1-rec-2",
7070
"resolvedUrl": "https://example.com/slate-1-rec-2",
7171
"title": "Slate 1, Recommendation 2",

Tests iOS/HomeTests.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class HomeTests: XCTestCase {
255255

256256
if apiRequest.isToSaveAnItem {
257257
defer { saveRequestExpectation.fulfill() }
258-
XCTAssertTrue(apiRequest.contains("http:\\/\\/localhost:8080\\/slate-1-rec-1"))
258+
XCTAssertEqual(apiRequest.inputURL, URL(string: "http://localhost:8080/slate-1-rec-1"))
259259
return .saveItem("save-recommendation-1")
260260
} else if apiRequest.isToArchiveAnItem {
261261
defer { archiveRequestExpectation.fulfill() }
@@ -288,13 +288,13 @@ class HomeTests: XCTestCase {
288288
server.routes.post("/graphql") { request, _ -> Response in
289289
let apiRequest = ClientAPIRequest(request)
290290
if apiRequest.isToSaveAnItem {
291-
if apiRequest.contains("http:\\/\\/localhost:8080\\/slate-1-rec-1") {
291+
if apiRequest.inputURL == URL(string: "http://localhost:8080/slate-1-rec-1") {
292292
return Response.saveItem("save-recommendation-1")
293-
} else if apiRequest.contains("https:\\/\\/example.com\\/slate-1-rec-2") {
293+
} else if apiRequest.inputURL == URL(string: "https://example.com/slate-1-rec-2") {
294294
return Response.saveItem("save-recommendation-2")
295295
}
296296
} else if apiRequest.isToArchiveAnItem {
297-
if apiRequest.contains("slate-1-rec-1-saved-item") {
297+
if apiRequest.contains("slate-1-rec-1") {
298298
XCTFail("Received archive request for unexpected item")
299299
} else {
300300
return Response.archive(apiRequest: apiRequest)

0 commit comments

Comments
 (0)