This repository has been archived by the owner on Feb 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCountdownModelTests.swift
78 lines (57 loc) · 1.71 KB
/
CountdownModelTests.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
72
73
74
75
76
77
78
//
// CountdownModelTests.swift
// TimerTests
//
// Created by Arman Abkar on 1/7/22.
//
import XCTest
@testable import Timer
class CountdownModelTests: XCTestCase {
let model = CountdownModel()
override func setUpWithError() throws {
model.counter = 1
model.duration = 100
model.selectedSeconds = 100
model.isRunning = true
}
override func tearDownWithError() throws {
model.resetTimer()
}
func test_progress() throws {
XCTAssertEqual(model.progress, 0.01)
}
func test_timeFormatter() throws {
XCTAssertEqual(model.timeFormatter, "00:01:39")
}
func test_completed() throws {
model.duration = 1
model.isRunning = false
XCTAssertTrue(model.completed())
}
func test_updateTimer() throws {
model.updateTimer(1)
XCTAssertEqual(model.duration, 100)
}
func test_resetTimer() throws {
model.resetTimer()
XCTAssertFalse(model.isRunning)
XCTAssertEqual(model.duration, model.storedDuration)
XCTAssertEqual(model.counter, 0)
XCTAssertEqual(model.selectedHours, 0)
XCTAssertEqual(model.selectedMinutes, 0)
XCTAssertEqual(model.selectedSeconds, 0)
}
func test_receiveTimerUpdate() throws {
model.receiveTimerUpdate()
XCTAssertEqual(model.counter, 2)
}
func test_disabledAction() throws {
model.duration = 0.1
XCTAssertTrue(model.disabledAction())
}
func test_playPauseAction() throws {
model.isRunning = false
model.playPauseAction()
XCTAssertTrue(model.isRunning)
}
}