Skip to content

Commit dd06e9a

Browse files
committed
Added first view based test
1 parent e35f96d commit dd06e9a

File tree

4 files changed

+19
-26
lines changed

4 files changed

+19
-26
lines changed
3.92 KB
Loading

Example/Tests/Tests.m

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,22 @@
66
// Copyright (c) 2014 Felix Krause. All rights reserved.
77
//
88

9-
SpecBegin(InitialSpecs)
10-
11-
describe(@"these will fail", ^{
9+
#import "TSMessage.h"
10+
#import "TSMessageView.h"
1211

13-
it(@"can do maths", ^{
14-
expect(1).to.equal(2);
15-
});
12+
SpecBegin(InitialSpecs)
1613

17-
it(@"can read", ^{
18-
expect(@"number").to.equal(@"string");
14+
describe(@"Show a new TSMessage notification", ^{
15+
before(^{
16+
[UIView setAnimationsEnabled:NO];
17+
[TSMessage dismissActiveNotification];
1918
});
2019

21-
it(@"will wait and fail", ^AsyncBlock {
20+
it(@"matches view (error message)", ^{
21+
[TSMessage showNotificationWithTitle:@"Error" type:TSMessageNotificationTypeError];
22+
TSMessageView *view = [[TSMessage queuedMessages] lastObject];
2223

23-
});
24-
});
25-
26-
describe(@"these will pass", ^{
27-
28-
it(@"can do maths", ^{
29-
expect(1).beLessThan(23);
30-
});
31-
32-
it(@"can read", ^{
33-
expect(@"team").toNot.contain(@"I");
34-
});
35-
36-
it(@"will wait and succeed", ^AsyncBlock {
37-
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
38-
done();
39-
});
24+
expect(view).to.haveValidSnapshotNamed(@"TSMessageViewErrorDefault");
4025
});
4126
});
4227

Pod/Classes/TSMessage.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) {
163163
/** Indicates whether a notification is currently active. */
164164
+ (BOOL)isNotificationActive;
165165

166+
/** Returns the currently queued array of TSMessageView */
167+
+ (NSArray *)queuedMessages;
168+
166169
/** Prepares the notification view to be displayed in the future. It is queued and then
167170
displayed in fadeInCurrentNotification.
168171
You don't have to use this method. */

Pod/Classes/TSMessage.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ + (BOOL)isNotificationActive
404404
return notificationActive;
405405
}
406406

407+
+ (NSArray *)queuedMessages
408+
{
409+
return [TSMessage sharedMessage].messages;
410+
}
411+
407412
+ (UIViewController *)defaultViewController
408413
{
409414
__strong UIViewController *defaultViewController = _defaultViewController;

0 commit comments

Comments
 (0)