Skip to content

Commit

Permalink
Added first view based test
Browse files Browse the repository at this point in the history
  • Loading branch information
KrauseFx committed Aug 25, 2014
1 parent e35f96d commit dd06e9a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 11 additions & 26 deletions Example/Tests/Tests.m
Expand Up @@ -6,37 +6,22 @@
// Copyright (c) 2014 Felix Krause. All rights reserved.
//

SpecBegin(InitialSpecs)

describe(@"these will fail", ^{
#import "TSMessage.h"
#import "TSMessageView.h"

it(@"can do maths", ^{
expect(1).to.equal(2);
});
SpecBegin(InitialSpecs)

it(@"can read", ^{
expect(@"number").to.equal(@"string");
describe(@"Show a new TSMessage notification", ^{
before(^{
[UIView setAnimationsEnabled:NO];
[TSMessage dismissActiveNotification];
});

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

});
});

describe(@"these will pass", ^{

it(@"can do maths", ^{
expect(1).beLessThan(23);
});

it(@"can read", ^{
expect(@"team").toNot.contain(@"I");
});

it(@"will wait and succeed", ^AsyncBlock {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
done();
});
expect(view).to.haveValidSnapshotNamed(@"TSMessageViewErrorDefault");
});
});

Expand Down
3 changes: 3 additions & 0 deletions Pod/Classes/TSMessage.h
Expand Up @@ -163,6 +163,9 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) {
/** Indicates whether a notification is currently active. */
+ (BOOL)isNotificationActive;

/** Returns the currently queued array of TSMessageView */
+ (NSArray *)queuedMessages;

/** Prepares the notification view to be displayed in the future. It is queued and then
displayed in fadeInCurrentNotification.
You don't have to use this method. */
Expand Down
5 changes: 5 additions & 0 deletions Pod/Classes/TSMessage.m
Expand Up @@ -404,6 +404,11 @@ + (BOOL)isNotificationActive
return notificationActive;
}

+ (NSArray *)queuedMessages
{
return [TSMessage sharedMessage].messages;
}

+ (UIViewController *)defaultViewController
{
__strong UIViewController *defaultViewController = _defaultViewController;
Expand Down

0 comments on commit dd06e9a

Please sign in to comment.