Skip to content

Commit 076b329

Browse files
committed
add unit tests
1 parent 10fe2da commit 076b329

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

Conjugar.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
038E031E22734800005CFC96 /* URLProtocolStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = 038E031D22734800005CFC96 /* URLProtocolStub.swift */; };
1717
038E03202273BF29005CFC96 /* RatingsFetcherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 038E031F2273BF29005CFC96 /* RatingsFetcherTests.swift */; };
1818
038E032222760A40005CFC96 /* UIViewExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 038E032122760A40005CFC96 /* UIViewExtensionsTests.swift */; };
19+
038E0324227617FC005CFC96 /* UIApplicationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 038E0323227617FC005CFC96 /* UIApplicationTests.swift */; };
1920
E10178021F3F753400F0BC97 /* UIViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E10178011F3F753400F0BC97 /* UIViewExtensions.swift */; };
2021
E107B08B1EB66CE6004C5E91 /* verbs.xml in Resources */ = {isa = PBXBuildFile; fileRef = E107B08A1EB66CE6004C5E91 /* verbs.xml */; };
2122
E107B0921EB66F28004C5E91 /* VerbParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = E107B0911EB66F28004C5E91 /* VerbParser.swift */; };
@@ -159,6 +160,7 @@
159160
038E031D22734800005CFC96 /* URLProtocolStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLProtocolStub.swift; sourceTree = "<group>"; };
160161
038E031F2273BF29005CFC96 /* RatingsFetcherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RatingsFetcherTests.swift; sourceTree = "<group>"; };
161162
038E032122760A40005CFC96 /* UIViewExtensionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewExtensionsTests.swift; sourceTree = "<group>"; };
163+
038E0323227617FC005CFC96 /* UIApplicationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIApplicationTests.swift; sourceTree = "<group>"; };
162164
E10178011F3F753400F0BC97 /* UIViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewExtensions.swift; sourceTree = "<group>"; };
163165
E107B08A1EB66CE6004C5E91 /* verbs.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = verbs.xml; sourceTree = "<group>"; };
164166
E107B0911EB66F28004C5E91 /* VerbParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VerbParser.swift; sourceTree = "<group>"; };
@@ -419,6 +421,7 @@
419421
038E03122270A868005CFC96 /* IntExtensionTests.swift */,
420422
038E031F2273BF29005CFC96 /* RatingsFetcherTests.swift */,
421423
038E03142270A9FB005CFC96 /* TestGameCenterTests.swift */,
424+
038E0323227617FC005CFC96 /* UIApplicationTests.swift */,
422425
038E031922711B76005CFC96 /* UIViewControllerExtensionTests.swift */,
423426
038E032122760A40005CFC96 /* UIViewExtensionsTests.swift */,
424427
);
@@ -839,6 +842,7 @@
839842
isa = PBXSourcesBuildPhase;
840843
buildActionMask = 2147483647;
841844
files = (
845+
038E0324227617FC005CFC96 /* UIApplicationTests.swift in Sources */,
842846
038E03182270AC01005CFC96 /* DeviceUtilityTests.swift in Sources */,
843847
E12D06A31F5E85A200CDD54E /* VerbCellTests.swift in Sources */,
844848
038E032222760A40005CFC96 /* UIViewExtensionsTests.swift in Sources */,
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//
2+
// UIApplicationTests.swift
3+
// ConjugarTests
4+
//
5+
// Created by Joshua Adams on 4/28/19.
6+
// Copyright © 2019 Josh Adams. All rights reserved.
7+
//
8+
9+
import XCTest
10+
import UIKit
11+
@testable import Conjugar
12+
13+
class UIApplicationTests: XCTestCase {
14+
private let 🥥 = "🥥"
15+
private let 🥩 = "🥩"
16+
17+
func testNavigationController() {
18+
let vc = UIViewController()
19+
vc.title = 🥥
20+
let nc = UINavigationController()
21+
nc.pushViewController(vc, animated: false)
22+
XCTAssertEqual(UIApplication.topViewController(nc)?.title ?? 🥩, 🥥)
23+
}
24+
25+
func testTabBarController() {
26+
let tbc = UITabBarController()
27+
let vc = UIViewController()
28+
vc.title = 🥥
29+
tbc.viewControllers = [vc]
30+
XCTAssertEqual(UIApplication.topViewController(tbc)?.title ?? self.🥩, self.🥥)
31+
}
32+
33+
func testModalViewController() {
34+
let vc1 = UIViewController()
35+
let vc2 = UIViewController()
36+
let window = UIWindow(frame: UIScreen.main.bounds)
37+
window.rootViewController = vc1
38+
window.makeKeyAndVisible()
39+
vc2.title = 🥥
40+
let expectatiøn = expectation(description: "testPresentedViewController")
41+
vc1.present(vc2, animated: false, completion: {
42+
XCTAssertEqual(UIApplication.topViewController(vc1)?.title ?? self.🥩, self.🥥)
43+
expectatiøn.fulfill()
44+
})
45+
let timeout: TimeInterval = 1.0
46+
wait(for: [expectatiøn], timeout: timeout)
47+
}
48+
49+
func testVanillaViewController() {
50+
let vc = UIViewController()
51+
vc.title = 🥥
52+
XCTAssertEqual(UIApplication.topViewController(vc)?.title ?? 🥩, 🥥)
53+
}
54+
}

0 commit comments

Comments
 (0)