deep-linking-sample/Apps/Wikipedia/WikipediaUnitTests/Code/Notifications Tests/NotificationsCenterDetailViewModelWelcomeTests.swift
Javier Cicchelli 9bcdaa697b [Setup] Basic project structure (#1)
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
2023-04-08 18:37:13 +00:00

44 lines
2.2 KiB
Swift

import XCTest
@testable import Wikipedia
class NotificationsCenterDetailViewModelWelcomeTests: NotificationsCenterViewModelTests {
override var dataFileName: String {
return "notifications-welcome"
}
func testWelcome() throws {
let detailViewModel = try detailViewModelFromIdentifier(identifier: "1")
try testWelcomeText(detailViewModel: detailViewModel)
try testWelcomeImage(detailViewModel: detailViewModel)
try testWelcomeActions(detailViewModel: detailViewModel)
}
private func testWelcomeText(detailViewModel: NotificationsCenterDetailViewModel) throws {
XCTAssertEqual(detailViewModel.headerTitle, "Welcome message", "Invalid headerTitle")
XCTAssertEqual(detailViewModel.headerSubtitle, "English Wikipedia", "Invalid headerSubtitle")
XCTAssertEqual(detailViewModel.headerDate, "12/19/18", "Invalid headerDate")
XCTAssertEqual(detailViewModel.contentTitle, "Welcome!", "Invalid contentTitle")
XCTAssertEqual(detailViewModel.contentBody, "Welcome to Wikipedia, Jack The Cat! We\'re glad you\'re here.", "Invalid contentBody")
}
private func testWelcomeImage(detailViewModel: NotificationsCenterDetailViewModel) throws {
XCTAssertEqual(detailViewModel.headerImageName, "notifications-type-milestone", "Invalid headerImageName")
}
private func testWelcomeActions(detailViewModel: NotificationsCenterDetailViewModel) throws {
XCTAssertNotNil(detailViewModel.primaryAction, "Invalid primaryAction")
XCTAssertEqual(detailViewModel.secondaryActions.count, 0, "Invalid secondaryActions count")
let expectedPrimaryText = "Help:Getting started"
let expectedPrimaryURL: URL? = URL(string: "https://en.wikipedia.org/wiki/Help:Getting_started")!
let expectedPrimaryIcon: NotificationsCenterIconType = .document
let expectedPrimaryDestinationText = "On web"
try testActions(expectedText: expectedPrimaryText, expectedURL: expectedPrimaryURL, expectedIcon: expectedPrimaryIcon, expectedDestinationText: expectedPrimaryDestinationText, actionToTest: detailViewModel.primaryAction!, actionType: .gettingStarted)
}
}