-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathTestResultsSectionTitleDisplayInfoSpec.swift
64 lines (53 loc) · 2.37 KB
/
TestResultsSectionTitleDisplayInfoSpec.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
//
// TestResultsSectionTitleDisplayInfoSpec.swift
// FBSnapshotsViewerTests
//
// Created by Anton Domashnev on 11.06.17.
// Copyright © 2017 Anton Domashnev. All rights reserved.
//
import Quick
import Nimble
@testable import FBSnapshotsViewer
class TestResultsSectionTitleDisplayInfo_MockDateComponentsFormatter: DateComponentsFormatter {
var formattedValue: String?
override func string(from startDate: Date, to endDate: Date) -> String? {
return formattedValue
}
}
class TestResultsSectionTitleDisplayInfoSpec: QuickSpec {
override func spec() {
var build: Build!
var dateFormatter: TestResultsSectionTitleDisplayInfo_MockDateComponentsFormatter!
var displayInfo: TestResultsSectionTitleDisplayInfo!
beforeEach {
build = Build(date: Date(), applicationName: "FBSnapshotsViewer", fbReferenceImageDirectoryURLs: [URL(fileURLWithPath: "foo/bar", isDirectory: true)])
dateFormatter = TestResultsSectionTitleDisplayInfo_MockDateComponentsFormatter()
}
describe(".init") {
beforeEach {
displayInfo = TestResultsSectionTitleDisplayInfo(build: build, testContext: "TestContext", dateFormatter: dateFormatter)
}
it("initializes correct title") {
expect(displayInfo.title).to(equal("FBSnapshotsViewer | TestContext"))
}
context("when date can be formatter") {
beforeEach {
dateFormatter.formattedValue = "10 minutes"
displayInfo = TestResultsSectionTitleDisplayInfo(build: build, testContext: "TestContext", dateFormatter: dateFormatter)
}
it("initializes correct timeAgo") {
expect(displayInfo.timeAgo).to(equal("10 minutes ago"))
}
}
context("when date can not be formatter") {
beforeEach {
dateFormatter.formattedValue = nil
displayInfo = TestResultsSectionTitleDisplayInfo(build: build, testContext: "TestContext", dateFormatter: dateFormatter)
}
it("initializes correct timeAgo") {
expect(displayInfo.timeAgo).to(equal("Just now"))
}
}
}
}
}