-
Notifications
You must be signed in to change notification settings - Fork 0
/
Comic_Tests.swift
71 lines (59 loc) · 2.52 KB
/
Comic_Tests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@testable import MarvelComics_ios
import XCTest
final class MarvelComics_ios_Tests: XCTestCase {
var data: ComicDataWrapper.ComicDataContainer!
override func setUpWithError() throws {
let container: ComicDataWrapper = try TestUtils().getMock(filename: "comics")
data = container.data!
}
func testContainerParser() throws {
XCTAssertEqual(data.results!.count, 20)
XCTAssertEqual(data.offset, 0)
XCTAssertEqual(data.limit, 20)
XCTAssertEqual(data.count, 20)
XCTAssertEqual(data.total, 59992)
}
func testDecoder() throws {
let comic = data.results![3]
XCTAssertEqual(comic.id, 323)
XCTAssertEqual(comic.title, "Ant-Man (2003) #2")
XCTAssertEqual(comic.textObjects!.count, 1)
XCTAssertEqual(
comic.textObjects![0].text,
"Ant-Man digs deeper to find out who is leaking secret information that threatens our national security.\r\n32 pgs./PARENTAL ADVISORY...$2.99"
)
XCTAssertEqual(comic.thumbnail!.path, "http://i.annihil.us/u/prod/marvel/i/mg/f/20/4bc69f33cafc0")
XCTAssertEqual(comic.thumbnail!.extension, "jpg")
XCTAssertEqual(comic.urls!.count, 1)
XCTAssertEqual(
comic.urls![0].url,
"http://marvel.com/comics/issue/323/ant-man_2003_2?utm_campaign=apiRef&utm_source=25a07f7adccf7328d3153451c26bd992"
)
}
func testHelperExtension() throws {
// object with empty data
let comic0 = data.results![0]
XCTAssertEqual(comic0.title, "Marvel Previews (2017)")
XCTAssertEqual(comic0.header, "")
XCTAssertNil(comic0.text)
XCTAssertEqual(comic0.texts, [])
XCTAssertNil(comic0.thumbnailUrl)
XCTAssertEqual(comic0.publicUrls, [])
// object with all data
let comic3 = data.results![3]
XCTAssertEqual(comic3.title, "Ant-Man (2003) #2")
XCTAssertEqual(comic3.header, "The Story")
XCTAssertEqual(
comic3.text,
"Ant-Man digs deeper to find out who is leaking secret information that threatens our national security.\r\n32 pgs./PARENTAL ADVISORY...$2.99"
)
XCTAssertEqual(
comic3.thumbnailUrl?.absoluteString,
"http://i.annihil.us/u/prod/marvel/i/mg/f/20/4bc69f33cafc0.jpg"
)
XCTAssertEqual(
comic3.publicUrls,
[URL(string: "http://marvel.com/comics/issue/323/ant-man_2003_2?utm_campaign=apiRef&utm_source=25a07f7adccf7328d3153451c26bd992")]
)
}
}