/
ARSerifNavigationViewControllerSpec.m
95 lines (67 loc) · 3.28 KB
/
ARSerifNavigationViewControllerSpec.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#import "ARSerifNavigationViewController.h"
#import <Artsy+UIColors/UIColor+ArtsyColors.h>
#import <Artsy+UIColors/UIColor+DebugColours.h>
@interface ARSerifNavigationViewController ()
@property (nonatomic, strong) UIApplication *sharedApplication;
@end
@interface ARSerifTestNavigationController: UIViewController
@end
SpecBegin(ARSerifNavigationViewController);
__block ARSerifNavigationViewController *subject;
describe(@"", ^{
// TODO: Orta - bring this back
pending(@"shows as a form in the center", ^{
// In order to use FBSnapshots + presentViewController:animated:
// the view controller has to exist within a key window + view controller
// structure, or present will not do it's work.
[ARTestContext useDevice:ARDeviceTypePad :^{
UIViewController *host = [[UIViewController alloc] init];
// Setting the frame after ensures that whatever internal
// method the UIWindow uses to get the app bounds is faked
UIWindow *window = [[UIWindow alloc] init];
window.frame = [[UIScreen mainScreen] bounds];
/// Add a dummy VC, then show the window
host = [[UIViewController alloc] init];
window.rootViewController = host;
[window makeKeyAndVisible];
host.view.backgroundColor = [UIColor whiteColor];
UIViewController *insideVC = [[UIViewController alloc] init];
insideVC.view.backgroundColor = [UIColor greenColor];
insideVC.title = @"Title";
// The presentation _probably_ requires a run-loop tick
// and so the waitUntil will delay this test to let it run.
waitUntil(^(DoneCallback done) {
subject = [[ARSerifNavigationViewController alloc] initWithRootViewController:insideVC];
[subject stubHorizontalSizeClass:UIUserInterfaceSizeClassRegular];
[host presentViewController:subject animated:NO completion:^{
done();
}];
});
// The host.view is useless here, we're not
// adding to it, contrary what you'd expect
expect(window).to.haveValidSnapshot();
// It sticks around otherwise.
window.hidden = YES;
window = nil;
}];
});
it(@"handles the back button correctly", ^{
UIViewController *insideVC = [[UIViewController alloc] init];
insideVC.view.backgroundColor = [UIColor greenColor];
insideVC.title = @"Title";
UIViewController *secondVC = [[UIViewController alloc] init];
secondVC.view.backgroundColor = [UIColor debugColourBlue];
secondVC.title = @"Title3";
subject = [[ARSerifNavigationViewController alloc] initWithRootViewController:insideVC];
[subject pushViewController:secondVC animated:NO];
expect(subject).to.haveValidSnapshot();
});
it(@"handles the fake navigation close button correctly", ^{
UIViewController *rootViewController = [[ARSerifTestNavigationController alloc] init];
subject = [[ARSerifNavigationViewController alloc] initWithRootViewController:rootViewController];
expect(subject).to.haveValidSnapshot();
});
});
SpecEnd
@implementation ARSerifTestNavigationController
@end