This PR contains all the work related to setting up this project as required to implement the [Assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) on top, as intended. To summarise this work: - [x] created a new **Xcode** project; - [x] cloned the `Wikipedia` app and inserted it into the **Xcode** project; - [x] created the `Locations` app and also, its `Libraries` package; - [x] created the `Shared` package to share dependencies between the apps; - [x] added a `Makefile` file and implemented some **environment** and **help** commands. Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Reviewed-on: rock-n-code/deep-linking-assignment#1
58 lines
3.6 KiB
Swift
58 lines
3.6 KiB
Swift
import XCTest
|
|
@testable import Wikipedia
|
|
|
|
class NotificationsCenterDetailViewModelUserGroupRightsChangeTests: NotificationsCenterViewModelTests {
|
|
|
|
override var dataFileName: String {
|
|
return "notifications-userRights"
|
|
}
|
|
|
|
func testUserRightsChange() throws {
|
|
let detailViewModel = try detailViewModelFromIdentifier(identifier: "1")
|
|
|
|
try testUserRightsChangeText(detailViewModel: detailViewModel)
|
|
try testUserRightsChangeImage(detailViewModel: detailViewModel)
|
|
try testUserRightsChangeActions(detailViewModel: detailViewModel)
|
|
}
|
|
|
|
private func testUserRightsChangeText(detailViewModel: NotificationsCenterDetailViewModel) throws {
|
|
XCTAssertEqual(detailViewModel.headerTitle, "From Jack The Cat", "Invalid headerTitle")
|
|
XCTAssertEqual(detailViewModel.headerSubtitle, "English Wikipedia", "Invalid headerSubtitle")
|
|
XCTAssertEqual(detailViewModel.headerDate, "5/13/20", "Invalid headerDate")
|
|
XCTAssertEqual(detailViewModel.contentTitle, "User rights change", "Invalid contentTitle")
|
|
XCTAssertEqual(detailViewModel.contentBody, "Your user rights were changed. You have been added to: Confirmed users.", "Invalid contentBody")
|
|
}
|
|
|
|
private func testUserRightsChangeImage(detailViewModel: NotificationsCenterDetailViewModel) throws {
|
|
XCTAssertEqual(detailViewModel.headerImageName, "notifications-type-user-rights", "Invalid headerImageName")
|
|
}
|
|
|
|
private func testUserRightsChangeActions(detailViewModel: NotificationsCenterDetailViewModel) throws {
|
|
|
|
XCTAssertNotNil(detailViewModel.primaryAction, "Invalid primaryAction")
|
|
XCTAssertEqual(detailViewModel.secondaryActions.count, 2, "Invalid secondaryActions count")
|
|
|
|
let expectedPrimaryText = "Special:ListGroupRights"
|
|
let expectedPrimaryURL: URL? = URL(string: "https://en.wikipedia.org/wiki/Special:ListGroupRights?")!
|
|
let expectedPrimaryIcon: NotificationsCenterIconType = .document
|
|
let expectedPrimaryDestinationText = "On web"
|
|
let expectedAction: NotificationsCenterActionData.LoggingLabel = .listGroupRights
|
|
try testActions(expectedText: expectedPrimaryText, expectedURL: expectedPrimaryURL, expectedIcon: expectedPrimaryIcon, expectedDestinationText: expectedPrimaryDestinationText, actionToTest: detailViewModel.primaryAction!, actionType: expectedAction)
|
|
|
|
let expectedText0 = "Special:ListGroupRights#confirmed"
|
|
let expectedURL0: URL? = URL(string: "https://en.wikipedia.org/wiki/Special:ListGroupRights?#confirmed")!
|
|
let expectedIcon0: NotificationsCenterIconType = .document
|
|
let expectedDestinationText0 = "On web"
|
|
let expectedAction0: NotificationsCenterActionData.LoggingLabel = .listGroupRights
|
|
try testActions(expectedText: expectedText0, expectedURL: expectedURL0, expectedIcon: expectedIcon0, expectedDestinationText: expectedDestinationText0, actionToTest: detailViewModel.secondaryActions[0], actionType: expectedAction0)
|
|
|
|
let expectedText1 = "Jack The Cat's user page"
|
|
let expectedURL1: URL? = URL(string: "https://en.wikipedia.org/wiki/User:Jack_The_Cat")!
|
|
let expectedIcon1: NotificationsCenterIconType = .person
|
|
let expectedDestinationText1 = "On web"
|
|
let expectedAction1: NotificationsCenterActionData.LoggingLabel = .senderPage
|
|
try testActions(expectedText: expectedText1, expectedURL: expectedURL1, expectedIcon: expectedIcon1, expectedDestinationText: expectedDestinationText1, actionToTest: detailViewModel.secondaryActions[1], actionType: expectedAction1)
|
|
}
|
|
|
|
}
|