-
-
Save delebedev/7801684 to your computer and use it in GitHub Desktop.
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
#import <Kiwi/Kiwi.h> | |
#import "WGTitleView.h" | |
//открываем доступ к внутренним свойствам | |
@interface WGTitleView () | |
@property (strong, nonatomic) UILabel *titleLabel; | |
@property (strong, nonatomic) UILabel *subtitleLabel; | |
- (void)onTap:(id)sender; | |
@end | |
SPEC_BEGIN(WGTitleViewSpec) | |
describe(@"WGTitleView", ^{ | |
context(@"initialization", ^{ | |
it(@"has initializer without parameters", ^{ | |
WGTitleView *titleView = [WGTitleView titleView]; | |
[[titleView.title should] beNil]; | |
[[titleView.subtitle should] beNil]; | |
}); | |
it(@"has initializer with title", ^{ | |
WGTitleView *titleView = [WGTitleView titleViewWithTitle:@"title"]; | |
[[titleView.title should] equal:@"title"]; | |
[[titleView.subtitle should] beNil]; | |
}); | |
it(@"has initalizer with title and subtitle", ^{ | |
WGTitleView *titleView = [WGTitleView titleViewWithTitle:@"title" subtitle:@"subtitle"]; | |
[[titleView.title should] equal:@"title"]; | |
[[titleView.subtitle should] equal:@"subtitle"]; | |
}); | |
}); | |
context(@"content", ^{ | |
it(@"should allow to set title and subtitle", ^{ | |
WGTitleView *titleView = [WGTitleView titleViewWithTitle:@"title" subtitle:@"subtitle"]; | |
[[titleView.titleLabel.text should] equal:@"title"]; | |
[[titleView.subtitleLabel.text should] equal:@"subtitle"]; | |
}); | |
}); | |
context(@"actions", ^{ | |
it(@"triggers touch handler on tap", ^{ | |
WGTitleView *titleView = [WGTitleView titleViewWithTitle:@"title" subtitle:@"subtitle"]; | |
__block BOOL tapped = NO; | |
titleView.tapHandler = ^(){ | |
tapped = YES; | |
}; | |
[titleView onTap:nil]; | |
[[theValue(tapped) should] beTrue]; | |
}); | |
}); | |
context(@"appearance", ^{ | |
__block WGTitleView *titleView; | |
beforeEach(^{ | |
titleView = [WGTitleView titleView]; | |
}); | |
it(@"has public properties to customize appearance", ^{ | |
titleView.titleColor = [UIColor redColor]; | |
[[titleView.titleLabel.textColor should] equal:[UIColor redColor]]; | |
titleView.subtitleColor = [UIColor blueColor]; | |
[[titleView.subtitleLabel.textColor should] equal:[UIColor blueColor]]; | |
titleView.titleFont = [UIFont systemFontOfSize:20.f]; | |
[[titleView.titleLabel.font should] equal:[UIFont systemFontOfSize:20.f]]; | |
titleView.subtitleFont = [UIFont systemFontOfSize:20.f]; | |
[[titleView.subtitleLabel.font should] equal:[UIFont systemFontOfSize:20.f]]; | |
}); | |
//не ясно почему, но этот тест отказывается работать | |
pending_(@"should have appearance selectors", ^{ | |
[WGTitleView appearance].titleColor = [UIColor redColor]; | |
[WGTitleView appearance].subtitleColor = [UIColor blueColor]; | |
[WGTitleView appearance].titleFont = [UIFont boldSystemFontOfSize:12.f]; | |
[WGTitleView appearance].subtitleFont = [UIFont boldSystemFontOfSize:9.f]; | |
UIView *superView = [[UIView alloc] init]; | |
[superView addSubview:titleView]; | |
[[titleView.titleLabel.font should] equal:[UIFont boldSystemFontOfSize:12.f]]; | |
[[titleView.subtitleLabel.font should] equal:[UIFont boldSystemFontOfSize:9.f]]; | |
[[titleView.titleLabel.textColor should] equal:[UIColor redColor]]; | |
[[titleView.subtitleLabel.textColor should] equal:[UIColor blueColor]]; | |
}); | |
}); | |
}); | |
SPEC_END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment