forked from slackhq/SlackTextViewController
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splits tests; fixes auto-completion tests
- Loading branch information
Ignacio Romero Zurbuchen
committed
Jan 18, 2016
1 parent
bd7a3d5
commit 3f45226
Showing
22 changed files
with
147 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
[ | ||
"-workspace", "Tests/SlackTextViewControllerTests.xcworkspace", | ||
"-scheme", "Tests", | ||
"-workspace", "SlackTextViewController/SlackTextViewController.xcworkspace", | ||
"-scheme", "SnapshotTests", | ||
"-sdk", "iphonesimulator", | ||
"-configuration", "Debug", | ||
"-destination", "name=iPhone 4s,OS=8.1", | ||
"-destination", "name=iPhone 5s,OS=8.1", | ||
"-destination", "name=iPhone 6s,OS=9.2", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
SlackTextViewController/SnapshotTests/AutoCompletionTests.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// | ||
// AutoCompletionTests.m | ||
// | ||
// Created by Ignacio Romero Z. on 18/1/16. | ||
// Copyright (c) 2016 Slack Technologies, Inc. All rights reserved. | ||
// | ||
|
||
#define EXP_SHORTHAND | ||
|
||
#import <UIKit/UIKit.h> | ||
#import <Specta/Specta.h> | ||
|
||
#import "EXPMatchers+FBSnapshotTestExtensions.h" | ||
#import "NSString+LoremIpsum.h" | ||
|
||
#import "SLKTextViewControllerStub.h" | ||
#import "SLKTextViewStub.h" | ||
|
||
SpecBegin(AutoCompletionTests) | ||
|
||
__block UIWindow *window = nil; | ||
__block SLKTextViewControllerStub *tvc = nil; | ||
__block UINavigationController *nvc = nil; | ||
|
||
beforeAll(^{ | ||
|
||
tvc = [[SLKTextViewControllerStub alloc] init]; | ||
nvc = [[UINavigationController alloc] initWithRootViewController:tvc]; | ||
nvc.view.backgroundColor = [UIColor whiteColor]; | ||
|
||
window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; | ||
window.rootViewController = [[UINavigationController alloc] initWithRootViewController:tvc]; | ||
window.backgroundColor = [UIColor redColor]; // Red color represents the keyboard area | ||
[window makeKeyAndVisible]; | ||
|
||
expect(tvc.view).toNot.beNil(); | ||
expect(nvc.view).toNot.beNil(); | ||
}); | ||
|
||
|
||
#pragma mark - Autocompletion Tests | ||
|
||
describe(@"Autocompletion Tests", ^{ | ||
|
||
beforeEach(^{ | ||
[tvc presentKeyboard:NO]; | ||
|
||
[tvc.textView slk_clearText:YES]; | ||
[tvc.textView slk_insertTextAtCaretRange:@"hello @"]; | ||
}); | ||
|
||
itShould(@"display the autocompletion view", ^{ | ||
|
||
expect(tvc.foundWord).to.beNil; | ||
expect(tvc.autoCompleting).to.beTruthy; | ||
|
||
return window; | ||
}); | ||
|
||
itShould(@"filter results in autocompletion view", ^{ | ||
|
||
[tvc.textView slk_insertTextAtCaretRange:@"an"]; | ||
|
||
// Auto-completion mode should be enabled | ||
expect(tvc.foundPrefix).to.equal(@"@"); | ||
expect(tvc.foundWord).to.equal(@"an"); | ||
expect(tvc.autoCompleting).to.beTruthy; | ||
|
||
return window; | ||
}); | ||
|
||
itShould(@"insert the first autocompletion item to the text input with prefix", ^{ | ||
|
||
[tvc acceptAutoCompletionWithString:@"Anna" keepPrefix:YES]; | ||
|
||
// Auto-completion mode should now be disabled | ||
expect(tvc.foundPrefix).to.beNil; | ||
expect(tvc.foundWord).to.beNil; | ||
expect(tvc.autoCompleting).to.beFalsy; | ||
|
||
expect(tvc.textView.text).to.equal(@"hello @Anna"); | ||
|
||
return window; | ||
}); | ||
}); | ||
|
||
|
||
SpecEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+32.7 KB
...nTestsSpec/filter_results_in_autocompletion_view_iphone6_portrait_ios9.2@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30.8 KB
...utocompletion_item_to_the_text_input_with_prefix_iphone6_portrait_ios9.2@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+23.9 KB
...ayTestsSpec/display_the_text_input_at_the_bottom_iphone6_portrait_ios9.2@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.2 KB
...ec/display_the_text_input_on_top_of_the_keyboard_iphone6_portrait_ios9.2@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.1 KB
...Spec/display_the_text_input_with_2_lines_of_text_iphone6_portrait_ios9.2@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+64.2 KB
...splay_the_text_input_with_multiple_lines_of_text_iphone6_portrait_ios9.2@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.2 KB
.../empty_the_text_input_after_hitting_right_button_iphone6_portrait_ios9.2@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters