mirror of
https://github.com/MessageKit/MessageKit.git
synced 2026-02-06 19:03:19 +00:00
Refactor MessagesViewControllerTests to use Quick/Nimble
This commit is contained in:
@@ -7,8 +7,11 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1F087D451FD274FD00E95A45 /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1F7FC8C71FD26F49006CC979 /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
1F087D461FD274FD00E95A45 /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1F7FC8C51FD26F33006CC979 /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
1F7FC8C61FD26F33006CC979 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F7FC8C51FD26F33006CC979 /* Quick.framework */; };
|
||||
1F7FC8C81FD26F49006CC979 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F7FC8C71FD26F49006CC979 /* Nimble.framework */; };
|
||||
1F7FC8CC1FD2700B006CC979 /* MessagesViewControllerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F7FC8CB1FD2700B006CC979 /* MessagesViewControllerSpec.swift */; };
|
||||
1F82D1431FB1B75B00B81A88 /* AvatarPosition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F82D1421FB1B75B00B81A88 /* AvatarPosition.swift */; };
|
||||
38C57C791F9AE3E50043CC03 /* SeparatorLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38C57C781F9AE3E50043CC03 /* SeparatorLine.swift */; };
|
||||
38C57C7C1F9AE4890043CC03 /* InputStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38C57C7B1F9AE4870043CC03 /* InputStackView.swift */; };
|
||||
@@ -85,10 +88,25 @@
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
1F087D431FD274D300E95A45 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
1F087D451FD274FD00E95A45 /* Nimble.framework in CopyFiles */,
|
||||
1F087D461FD274FD00E95A45 /* Quick.framework in CopyFiles */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
1F7FC8C31FD26F22006CC979 /* Carthage */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Carthage; sourceTree = "<group>"; };
|
||||
1F7FC8C51FD26F33006CC979 /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/iOS/Quick.framework; sourceTree = "<group>"; };
|
||||
1F7FC8C71FD26F49006CC979 /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/iOS/Nimble.framework; sourceTree = "<group>"; };
|
||||
1F7FC8CB1FD2700B006CC979 /* MessagesViewControllerSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesViewControllerSpec.swift; sourceTree = "<group>"; };
|
||||
1F82D1421FB1B75B00B81A88 /* AvatarPosition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvatarPosition.swift; sourceTree = "<group>"; };
|
||||
38C57C781F9AE3E50043CC03 /* SeparatorLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SeparatorLine.swift; sourceTree = "<group>"; };
|
||||
38C57C7B1F9AE4870043CC03 /* InputStackView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InputStackView.swift; sourceTree = "<group>"; };
|
||||
@@ -283,6 +301,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8962AC7D1F87AB230030B058 /* MessagesViewControllerTests.swift */,
|
||||
1F7FC8CB1FD2700B006CC979 /* MessagesViewControllerSpec.swift */,
|
||||
);
|
||||
path = ControllersTest;
|
||||
sourceTree = "<group>";
|
||||
@@ -457,6 +476,7 @@
|
||||
88916B281CF0DF2F00469F91 /* Sources */,
|
||||
88916B291CF0DF2F00469F91 /* Frameworks */,
|
||||
88916B2A1CF0DF2F00469F91 /* Resources */,
|
||||
1F087D431FD274D300E95A45 /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -605,6 +625,7 @@
|
||||
8962AC911F87AB860030B058 /* MessagesViewControllerTests.swift in Sources */,
|
||||
8962AC901F87AB7D0030B058 /* MessageDateHeaderViewTests.swift in Sources */,
|
||||
8962AC8F1F87AB7D0030B058 /* MessageInputBarTests.swift in Sources */,
|
||||
1F7FC8CC1FD2700B006CC979 /* MessagesViewControllerSpec.swift in Sources */,
|
||||
8962AC8A1F87AB7D0030B058 /* MessagesCollectionViewTests.swift in Sources */,
|
||||
8962AC8D1F87AB7D0030B058 /* MessageCollectionViewCellTests.swift in Sources */,
|
||||
8962AC961F87AB860030B058 /* SenderTests.swift in Sources */,
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 MessageKit
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
import Quick
|
||||
import Nimble
|
||||
@testable import MessageKit
|
||||
|
||||
final class MessagesViewControllerSpec: QuickSpec {
|
||||
|
||||
override func spec() {
|
||||
|
||||
var controller: MessagesViewController!
|
||||
|
||||
beforeEach {
|
||||
controller = MessagesViewController()
|
||||
}
|
||||
|
||||
describe("default property values") {
|
||||
|
||||
it("does not scroll to bottom on first layout") {
|
||||
expect(controller.scrollsToBottomOnFirstLayout).to(beFalse())
|
||||
}
|
||||
|
||||
it("does not scroll to bottom on begins editing") {
|
||||
expect(controller.scrollsToBottomOnKeybordBeginsEditing).to(beFalse())
|
||||
}
|
||||
|
||||
it("can become first responder") {
|
||||
expect(controller.canBecomeFirstResponder).to(beTrue())
|
||||
}
|
||||
|
||||
it("does not autorotate") {
|
||||
expect(controller.shouldAutorotate).to(beFalse())
|
||||
}
|
||||
|
||||
it("has an inputAccessoryView of type MessageInputBar") {
|
||||
expect(controller.inputAccessoryView).toNot(beNil())
|
||||
expect(controller.inputAccessoryView is MessageInputBar).to(beTrue())
|
||||
}
|
||||
|
||||
it("has a MessagesCollectionView") {
|
||||
expect(controller.messagesCollectionView).toNot(beNil())
|
||||
}
|
||||
}
|
||||
|
||||
describe("after viewDidLoad") {
|
||||
|
||||
beforeEach {
|
||||
controller.viewDidLoad()
|
||||
}
|
||||
|
||||
it("does not automatically adjust scroll view insets") {
|
||||
expect(controller.automaticallyAdjustsScrollViewInsets).to(beFalse())
|
||||
}
|
||||
|
||||
it("includes opaque bars in extended layout") {
|
||||
expect(controller.extendedLayoutIncludesOpaqueBars).to(beTrue())
|
||||
}
|
||||
|
||||
it("has a background color of white") {
|
||||
expect(controller.view.backgroundColor).to(be(UIColor.white))
|
||||
}
|
||||
|
||||
describe("messagesCollectionView properties") {
|
||||
|
||||
var messagesCollectionView: MessagesCollectionView!
|
||||
|
||||
beforeEach {
|
||||
messagesCollectionView = controller.messagesCollectionView
|
||||
}
|
||||
|
||||
it("uses interactive keyboard dismissal") {
|
||||
let interactive: UIScrollViewKeyboardDismissMode = .interactive
|
||||
expect(messagesCollectionView.keyboardDismissMode).to(be(interactive))
|
||||
}
|
||||
|
||||
it("it always bounces vertical") {
|
||||
expect(messagesCollectionView.alwaysBounceVertical).to(beTrue())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,10 +59,6 @@ class MessagesViewControllerTests: XCTestCase {
|
||||
XCTAssertTrue(sut.messagesCollectionView.collectionViewLayout is MessagesCollectionViewFlowLayout)
|
||||
}
|
||||
|
||||
func testMessageCollectionView_isNotNilAfterViewDidLoad() {
|
||||
XCTAssertNotNil(sut.messageInputBar)
|
||||
}
|
||||
|
||||
func testMessageCollectionView_hasMessageCollectionFlowLayoutAfterViewDidLoad() {
|
||||
let layout = sut.messagesCollectionView.collectionViewLayout
|
||||
|
||||
@@ -70,13 +66,6 @@ class MessagesViewControllerTests: XCTestCase {
|
||||
XCTAssertTrue(layout is MessagesCollectionViewFlowLayout)
|
||||
}
|
||||
|
||||
func testMessageInputBar_isNotNilAfterViewDidLoad() {
|
||||
XCTAssertNotNil(sut.messageInputBar)
|
||||
}
|
||||
|
||||
func testViewDidLoad_shouldSetBackgroundColorToWhite() {
|
||||
XCTAssertEqual(sut.view.backgroundColor, UIColor.white)
|
||||
}
|
||||
|
||||
func testViewDidLoad_shouldAddMessageCollectionViewInSubviews() {
|
||||
let messageColelctionViews = sut.view.subviews.filter { $0 is MessagesCollectionView }
|
||||
@@ -84,10 +73,6 @@ class MessagesViewControllerTests: XCTestCase {
|
||||
XCTAssertEqual(messageColelctionViews.count, 1)
|
||||
}
|
||||
|
||||
func testViewDidLoad_shouldSetAutomaticallyAdjustsScrollViewInsetsToFalse() {
|
||||
XCTAssertFalse(sut.automaticallyAdjustsScrollViewInsets)
|
||||
}
|
||||
|
||||
func testViewDidLoad_shouldSetCollectionViewDelegate() {
|
||||
let delegate = sut.messagesCollectionView.delegate
|
||||
|
||||
@@ -107,21 +92,6 @@ class MessagesViewControllerTests: XCTestCase {
|
||||
sut.messagesCollectionView.dataSource as? MessagesViewController)
|
||||
}
|
||||
|
||||
func testShouldAutorotate_isFalse() {
|
||||
XCTAssertFalse(sut.shouldAutorotate)
|
||||
}
|
||||
|
||||
func testInputAccessoryView_shouldReturnsMessageInputBarAfterViewDidLoad() {
|
||||
let inputAccessoryView = sut.inputAccessoryView
|
||||
|
||||
XCTAssertNotNil(inputAccessoryView)
|
||||
XCTAssertEqual(inputAccessoryView, sut.messageInputBar)
|
||||
}
|
||||
|
||||
func testCanBecomeFirstResponder_isTrue() {
|
||||
XCTAssertTrue(sut.canBecomeFirstResponder)
|
||||
}
|
||||
|
||||
func testNumberOfSectionWithoutData_isZero() {
|
||||
let messagesDataSource = MockMessagesDataSource()
|
||||
sut.messagesCollectionView.messagesDataSource = messagesDataSource
|
||||
|
||||
Reference in New Issue
Block a user