deep-linking-sample/Apps/Wikipedia/WikipediaUnitTests/Code/TalkPageNetworkDataTests.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

39 lines
2.1 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import XCTest
@testable import Wikipedia
@testable import WMF
class TalkPageNetworkDataTests: XCTestCase {
let session = MWKDataStore.temporary().session
func testLocalJsonDecodesToTalkPage() {
guard let json = wmf_bundle().wmf_data(fromContentsOfFile: TalkPageTestHelpers.TalkPageJSONType.original.fileName, ofType: "json") else {
XCTFail("Failure pulling local talk page json")
return
}
do {
let result: NetworkBase = try session.jsonDecodeData(data: json)
let topics = result.topics
XCTAssertEqual(topics.count, 6, "Unexpected topic count")
XCTAssertEqual(topics[1].html, "Lets talk about talk pages", "Unexpected topic title")
XCTAssertEqual(topics[1].replies.count, 3, "Unexpected replies count")
let firstItem = topics[1].replies[0]
XCTAssertEqual(firstItem.html, "Hello, I am testing a new topic from the <a href='./IOS' title='IOS'>iOS</a> app. It is fun. <a href='./Special:Contributions/47.184.10.84' title='Special:Contributions/47.184.10.84'>47.184.10.84</a> 20:50, 21 June 2019 (UTC)", "Unexpected reply text")
XCTAssertEqual(firstItem.depth, 0, "Unexpected reply depth")
let secondItem = topics[1].replies[1]
XCTAssertEqual(secondItem.html, "Hello back! This is a nested reply. <a href='./User:TSevener_(WMF)' title='User:TSevener (WMF)'>TSevener (WMF)</a> (<a href='./User_talk:TSevener_(WMF)' title='User talk:TSevener (WMF)'>talk</a>) 20:51, 21 June 2019 (UTC)", "Unexpected reply text")
XCTAssertEqual(secondItem.depth, 1, "Unexpected reply depth")
let thirdItem = topics[1].replies[2]
XCTAssertEqual(thirdItem.html, "Yes I see, I am nested as well. <a href='./Special:Contributions/47.184.10.84' title='Special:Contributions/47.184.10.84'>47.184.10.84</a> 20:52, 21 June 2019 (UTC)", "Unexpected reply text")
XCTAssertEqual(thirdItem.depth, 2, "Unexpected reply depth")
} catch let error {
XCTFail("Talk Page json failed to decode \(error)")
}
}
}