From 378e60fcf2c73ec96d528cb53549a2d516e9d2c6 Mon Sep 17 00:00:00 2001 From: Shawn Gong Date: Mon, 17 Feb 2020 19:18:21 -0800 Subject: [PATCH] Fix tests --- Cartfile.resolved | 4 ++-- .../MessagesDisplayDelegateTests.swift | 8 ++++---- Tests/ViewsTests/AvatarViewTests.swift | 12 +++++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 7acd3164..87c9aee3 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,3 @@ -github "Quick/Nimble" "v8.0.1" -github "Quick/Quick" "v2.0.0" +github "Quick/Nimble" "v8.0.5" +github "Quick/Quick" "v2.2.0" github "nathantannar4/InputBarAccessoryView" "4.3.0" diff --git a/Tests/ProtocolsTests/MessagesDisplayDelegateTests.swift b/Tests/ProtocolsTests/MessagesDisplayDelegateTests.swift index 6cbfb632..717d154e 100644 --- a/Tests/ProtocolsTests/MessagesDisplayDelegateTests.swift +++ b/Tests/ProtocolsTests/MessagesDisplayDelegateTests.swift @@ -71,7 +71,7 @@ class MessagesDisplayDelegateTests: XCTestCase { at: IndexPath(item: 0, section: 0), in: sut.messagesCollectionView) - XCTAssertEqual(backgroundColor, .white) + XCTAssertEqual(backgroundColor, .backgroundColor) } func testBackgroundColorForMessageWithEmoji_returnsClearForDefault() { @@ -143,7 +143,7 @@ class TextMessageDisplayDelegateTests: XCTestCase { at: IndexPath(item: 0, section: 0), in: sut.messagesCollectionView) - XCTAssertEqual(textColor, .white) + XCTAssertEqual(textColor, .backgroundColor) } func testTextColorFromYou_returnsDarkTextForDefault() { @@ -151,7 +151,7 @@ class TextMessageDisplayDelegateTests: XCTestCase { at: IndexPath(item: 0, section: 0), in: sut.messagesCollectionView) - XCTAssertEqual(textColor, .darkText) + XCTAssertEqual(textColor, .labelColor) } func testTextColorWithoutDataSource_returnsDarkTextForDefault() { @@ -161,7 +161,7 @@ class TextMessageDisplayDelegateTests: XCTestCase { at: IndexPath(item: 0, section: 0), in: sut.messagesCollectionView) - XCTAssertEqual(textColor, .darkText) + XCTAssertEqual(textColor, .labelColor) } func testEnableDetectors_returnsEmptyForDefault() { diff --git a/Tests/ViewsTests/AvatarViewTests.swift b/Tests/ViewsTests/AvatarViewTests.swift index e919f141..602632c7 100644 --- a/Tests/ViewsTests/AvatarViewTests.swift +++ b/Tests/ViewsTests/AvatarViewTests.swift @@ -42,7 +42,9 @@ class AvatarViewTests: XCTestCase { func testNoParams() { XCTAssertEqual(avatarView.layer.cornerRadius, 15.0) - XCTAssertEqual(avatarView.backgroundColor, UIColor.gray) + // For certain dynamic colors, need to compare cgColor in XCTest + // https://stackoverflow.com/questions/58065340/how-to-compare-two-uidynamicprovidercolor + XCTAssertEqual(avatarView.backgroundColor!.cgColor, UIColor.grayColor.cgColor) } func testWithImage() { @@ -50,7 +52,7 @@ class AvatarViewTests: XCTestCase { avatarView.set(avatar: avatar) XCTAssertEqual(avatar.initials, "?") XCTAssertEqual(avatarView.layer.cornerRadius, 15.0) - XCTAssertEqual(avatarView.backgroundColor, UIColor.gray) + XCTAssertEqual(avatarView.backgroundColor!.cgColor, UIColor.grayColor.cgColor) } func testInitialsOnly() { @@ -59,13 +61,13 @@ class AvatarViewTests: XCTestCase { XCTAssertEqual(avatarView.initials, avatar.initials) XCTAssertEqual(avatar.initials, "DL") XCTAssertEqual(avatarView.layer.cornerRadius, 15.0) - XCTAssertEqual(avatarView.backgroundColor, UIColor.gray) + XCTAssertEqual(avatarView.backgroundColor!.cgColor, UIColor.grayColor.cgColor) } func testSetBackground() { - XCTAssertEqual(avatarView.backgroundColor, UIColor.gray) + XCTAssertEqual(avatarView.backgroundColor!.cgColor, UIColor.grayColor.cgColor) avatarView.backgroundColor = UIColor.red - XCTAssertEqual(avatarView.backgroundColor, UIColor.red) + XCTAssertEqual(avatarView.backgroundColor!, UIColor.red) } func testGetImage() {