Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vermont42 committed Apr 28, 2019
1 parent 10fe2da commit 076b329
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Conjugar.xcodeproj/project.pbxproj
Expand Up @@ -16,6 +16,7 @@
038E031E22734800005CFC96 /* URLProtocolStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = 038E031D22734800005CFC96 /* URLProtocolStub.swift */; };
038E03202273BF29005CFC96 /* RatingsFetcherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 038E031F2273BF29005CFC96 /* RatingsFetcherTests.swift */; };
038E032222760A40005CFC96 /* UIViewExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 038E032122760A40005CFC96 /* UIViewExtensionsTests.swift */; };
038E0324227617FC005CFC96 /* UIApplicationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 038E0323227617FC005CFC96 /* UIApplicationTests.swift */; };
E10178021F3F753400F0BC97 /* UIViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E10178011F3F753400F0BC97 /* UIViewExtensions.swift */; };
E107B08B1EB66CE6004C5E91 /* verbs.xml in Resources */ = {isa = PBXBuildFile; fileRef = E107B08A1EB66CE6004C5E91 /* verbs.xml */; };
E107B0921EB66F28004C5E91 /* VerbParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = E107B0911EB66F28004C5E91 /* VerbParser.swift */; };
Expand Down Expand Up @@ -159,6 +160,7 @@
038E031D22734800005CFC96 /* URLProtocolStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLProtocolStub.swift; sourceTree = "<group>"; };
038E031F2273BF29005CFC96 /* RatingsFetcherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RatingsFetcherTests.swift; sourceTree = "<group>"; };
038E032122760A40005CFC96 /* UIViewExtensionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewExtensionsTests.swift; sourceTree = "<group>"; };
038E0323227617FC005CFC96 /* UIApplicationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIApplicationTests.swift; sourceTree = "<group>"; };
E10178011F3F753400F0BC97 /* UIViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewExtensions.swift; sourceTree = "<group>"; };
E107B08A1EB66CE6004C5E91 /* verbs.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = verbs.xml; sourceTree = "<group>"; };
E107B0911EB66F28004C5E91 /* VerbParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VerbParser.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -419,6 +421,7 @@
038E03122270A868005CFC96 /* IntExtensionTests.swift */,
038E031F2273BF29005CFC96 /* RatingsFetcherTests.swift */,
038E03142270A9FB005CFC96 /* TestGameCenterTests.swift */,
038E0323227617FC005CFC96 /* UIApplicationTests.swift */,
038E031922711B76005CFC96 /* UIViewControllerExtensionTests.swift */,
038E032122760A40005CFC96 /* UIViewExtensionsTests.swift */,
);
Expand Down Expand Up @@ -839,6 +842,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
038E0324227617FC005CFC96 /* UIApplicationTests.swift in Sources */,
038E03182270AC01005CFC96 /* DeviceUtilityTests.swift in Sources */,
E12D06A31F5E85A200CDD54E /* VerbCellTests.swift in Sources */,
038E032222760A40005CFC96 /* UIViewExtensionsTests.swift in Sources */,
Expand Down
54 changes: 54 additions & 0 deletions ConjugarTests/Utils/UIApplicationTests.swift
@@ -0,0 +1,54 @@
//
// UIApplicationTests.swift
// ConjugarTests
//
// Created by Joshua Adams on 4/28/19.
// Copyright © 2019 Josh Adams. All rights reserved.
//

import XCTest
import UIKit
@testable import Conjugar

class UIApplicationTests: XCTestCase {
private let 🥥 = "🥥"
private let 🥩 = "🥩"

func testNavigationController() {
let vc = UIViewController()
vc.title = 🥥
let nc = UINavigationController()
nc.pushViewController(vc, animated: false)
XCTAssertEqual(UIApplication.topViewController(nc)?.title ?? 🥩, 🥥)
}

func testTabBarController() {
let tbc = UITabBarController()
let vc = UIViewController()
vc.title = 🥥
tbc.viewControllers = [vc]
XCTAssertEqual(UIApplication.topViewController(tbc)?.title ?? self.🥩, self.🥥)
}

func testModalViewController() {
let vc1 = UIViewController()
let vc2 = UIViewController()
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = vc1
window.makeKeyAndVisible()
vc2.title = 🥥
let expectatiøn = expectation(description: "testPresentedViewController")
vc1.present(vc2, animated: false, completion: {
XCTAssertEqual(UIApplication.topViewController(vc1)?.title ?? self.🥩, self.🥥)
expectatiøn.fulfill()
})
let timeout: TimeInterval = 1.0
wait(for: [expectatiøn], timeout: timeout)
}

func testVanillaViewController() {
let vc = UIViewController()
vc.title = 🥥
XCTAssertEqual(UIApplication.topViewController(vc)?.title ?? 🥩, 🥥)
}
}

0 comments on commit 076b329

Please sign in to comment.