@@ -15,127 +15,189 @@ @interface InstabugSampleTests : XCTestCase
15
15
16
16
@implementation InstabugSampleTests
17
17
18
+ static const NSTimeInterval kTimeout = 30.0 ;
19
+
18
20
- (void )testShowWelcomeMessageWithMode {
19
21
id mock = OCMClassMock ([InstabugFlutterPlugin class ]);
20
22
InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc ] init ];
21
- id result;
22
23
23
24
NSArray *arguments = [NSArray arrayWithObjects: @" WelcomeMessageMode.live" , nil ];
24
25
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" showWelcomeMessageWithMode:" arguments: arguments];
25
26
[[[mock stub ] classMethod ] showWelcomeMessageWithMode: @" WelcomeMessageMode.live" ];
26
- [instabug handleMethodCall: call result: result];
27
+
28
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Result is called" ];
29
+ [instabug handleMethodCall: call result: ^(id _Nullable result) {
30
+ XCTAssertNil (result);
31
+ [expectation fulfill ];
32
+ }];
33
+
27
34
[[[mock verify ] classMethod ] showWelcomeMessageWithMode: @" WelcomeMessageMode.live" ];
35
+ [self waitForExpectationsWithTimeout: kTimeout handler: nil ];
28
36
}
29
37
30
38
- (void )testIdentifyUserWithEmail {
31
39
id mock = OCMClassMock ([InstabugFlutterPlugin class ]);
32
40
InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc ] init ];
33
- id result;
34
41
35
42
NSArray *arguments = [
NSArray arrayWithObjects: @" [email protected] " ,
@" name" ,
nil ];
36
43
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" identifyUserWithEmail:name:" arguments: arguments];
37
44
[[[mock
stub ]
classMethod ]
identifyUserWithEmail: @" [email protected] " name: @" name" ];
38
- [instabug handleMethodCall: call result: result];
45
+
46
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Result is called" ];
47
+ [instabug handleMethodCall: call result: ^(id _Nullable result) {
48
+ XCTAssertNil (result);
49
+ [expectation fulfill ];
50
+ }];
51
+
39
52
[[[mock
verify ]
classMethod ]
identifyUserWithEmail: @" [email protected] " name: @" name" ];
53
+ [self waitForExpectationsWithTimeout: kTimeout handler: nil ];
40
54
}
41
55
42
56
- (void )testLogOut {
43
57
id mock = OCMClassMock ([InstabugFlutterPlugin class ]);
44
58
InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc ] init ];
45
- id result;
46
59
47
60
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" logOut" arguments: NULL ];
48
61
[[[mock stub ] classMethod ] logOut ];
49
- [instabug handleMethodCall: call result: result];
62
+
63
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Result is called" ];
64
+ [instabug handleMethodCall: call result: ^(id _Nullable result) {
65
+ XCTAssertNil (result);
66
+ [expectation fulfill ];
67
+ }];
68
+
50
69
[[[mock verify ] classMethod ] logOut ];
70
+ [self waitForExpectationsWithTimeout: kTimeout handler: nil ];
51
71
}
52
72
53
73
- (void )testAppendTags {
54
74
id mock = OCMClassMock ([InstabugFlutterPlugin class ]);
55
75
InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc ] init ];
56
- id result;
57
76
58
77
NSArray *tags = [NSArray arrayWithObjects: @" tag1" , @" tag2" , nil ];
59
78
NSArray *arguments = [NSArray arrayWithObjects: tags, nil ];
60
79
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" appendTags:" arguments: arguments];
61
80
[[[mock stub ] classMethod ] appendTags: tags];
62
- [instabug handleMethodCall: call result: result];
81
+
82
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Result is called" ];
83
+ [instabug handleMethodCall: call result: ^(id _Nullable result) {
84
+ XCTAssertNil (result);
85
+ [expectation fulfill ];
86
+ }];
87
+
63
88
[[[mock verify ] classMethod ] appendTags: tags];
89
+ [self waitForExpectationsWithTimeout: kTimeout handler: nil ];
64
90
}
65
91
66
92
- (void )testShowBugReportingWithReportTypeAndOptions {
67
93
id mock = OCMClassMock ([InstabugFlutterPlugin class ]);
68
94
InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc ] init ];
69
- id result;
70
95
71
96
NSArray *options = [NSArray arrayWithObjects: @" commentFieldRequired" , @" disablePostSendingDialog" , nil ];
72
97
NSArray *arguments = [NSArray arrayWithObjects: @" bug" , options, nil ];
73
98
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" showBugReportingWithReportTypeAndOptions:options:" arguments: arguments];
74
99
[[[mock stub ] classMethod ] showBugReportingWithReportTypeAndOptions: @" bug" options: options];
75
- [instabug handleMethodCall: call result: result];
100
+
101
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Result is called" ];
102
+ [instabug handleMethodCall: call result: ^(id _Nullable result) {
103
+ XCTAssertNil (result);
104
+ [expectation fulfill ];
105
+ }];
106
+
76
107
[[[mock verify ] classMethod ] showBugReportingWithReportTypeAndOptions: @" bug" options: options];
108
+ [self waitForExpectationsWithTimeout: kTimeout handler: nil ];
77
109
}
78
110
79
111
- (void )testSetSessionProfilerEnabled {
80
112
id mock = OCMClassMock ([InstabugFlutterPlugin class ]);
81
113
InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc ] init ];
82
- id result;
83
114
84
115
NSArray *arguments = [NSArray arrayWithObjects: @(1 ), nil ];
85
116
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" setSessionProfilerEnabled:" arguments: arguments];
86
117
[[[mock stub ] classMethod ] setSessionProfilerEnabled: @(1 )];
87
- [instabug handleMethodCall: call result: result];
118
+
119
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Result is called" ];
120
+ [instabug handleMethodCall: call result: ^(id _Nullable result) {
121
+ XCTAssertNil (result);
122
+ [expectation fulfill ];
123
+ }];
124
+
88
125
[[[mock verify ] classMethod ] setSessionProfilerEnabled: @(1 )];
126
+ [self waitForExpectationsWithTimeout: kTimeout handler: nil ];
89
127
}
90
128
91
129
- (void )testSetPrimaryColor {
92
130
id mock = OCMClassMock ([InstabugFlutterPlugin class ]);
93
131
InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc ] init ];
94
- id result;
95
132
96
133
NSArray *arguments = [NSArray arrayWithObjects: @(1123123123121 ), nil ];
97
134
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" setPrimaryColor:" arguments: arguments];
98
135
[[[mock stub ] classMethod ] setPrimaryColor: @(1123123123121 )];
99
- [instabug handleMethodCall: call result: result];
136
+
137
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Result is called" ];
138
+ [instabug handleMethodCall: call result: ^(id _Nullable result) {
139
+ XCTAssertNil (result);
140
+ [expectation fulfill ];
141
+ }];
142
+
100
143
[[[mock verify ] classMethod ] setPrimaryColor: @(1123123123121 )];
144
+ [self waitForExpectationsWithTimeout: kTimeout handler: nil ];
101
145
}
102
146
103
147
- (void )testAddFileAttachmentWithData {
104
148
id mock = OCMClassMock ([InstabugFlutterPlugin class ]);
105
149
InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc ] init ];
106
- id result;
107
150
108
151
FlutterStandardTypedData *data;
109
152
NSArray *arguments = [NSArray arrayWithObjects: data, nil ];
110
153
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" addFileAttachmentWithData:" arguments: arguments];
111
154
[[[mock stub ] classMethod ] addFileAttachmentWithData: data];
112
- [instabug handleMethodCall: call result: result];
155
+
156
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Result is called" ];
157
+ [instabug handleMethodCall: call result: ^(id _Nullable result) {
158
+ XCTAssertNil (result);
159
+ [expectation fulfill ];
160
+ }];
161
+
113
162
[[[mock verify ] classMethod ] addFileAttachmentWithData: data];
163
+ [self waitForExpectationsWithTimeout: kTimeout handler: nil ];
114
164
}
115
165
116
166
- (void )testSetEnabledAttachmentTypes {
117
167
id mock = OCMClassMock ([InstabugFlutterPlugin class ]);
118
168
InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc ] init ];
119
- id result;
120
169
121
170
NSArray *arguments = [NSArray arrayWithObjects: @(1 ),@(1 ),@(1 ),@(1 ), nil ];
122
171
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" setEnabledAttachmentTypes:extraScreenShot:galleryImage:screenRecording:" arguments: arguments];
123
172
[[[mock stub ] classMethod ] setEnabledAttachmentTypes: @(1 ) extraScreenShot: @(1 ) galleryImage: @(1 ) screenRecording: @(1 ) ];
124
- [instabug handleMethodCall: call result: result];
173
+
174
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Result is called" ];
175
+ [instabug handleMethodCall: call result: ^(id _Nullable result) {
176
+ XCTAssertNil (result);
177
+ [expectation fulfill ];
178
+ }];
179
+
125
180
[[[mock verify ] classMethod ] setEnabledAttachmentTypes: @(1 ) extraScreenShot: @(1 ) galleryImage: @(1 ) screenRecording: @(1 )];
181
+ [self waitForExpectationsWithTimeout: kTimeout handler: nil ];
126
182
}
127
183
128
184
- (void )testSetEmailFieldRequiredForFeatureRequests {
129
185
id mock = OCMClassMock ([InstabugFlutterPlugin class ]);
130
186
InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc ] init ];
131
- id result;
132
187
133
188
NSArray *actions = [NSArray arrayWithObjects: @" reportBug" , @" requestNewFeature" , nil ];
134
189
NSArray *arguments = [NSArray arrayWithObjects: @(1 ), actions, nil ];
135
190
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" setEmailFieldRequiredForFeatureRequests:forAction:" arguments: arguments];
136
191
[[[mock stub ] classMethod ] setEmailFieldRequiredForFeatureRequests: @(1 ) forAction: actions];
137
- [instabug handleMethodCall: call result: result];
192
+
193
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Result is called" ];
194
+ [instabug handleMethodCall: call result: ^(id _Nullable result) {
195
+ XCTAssertNil (result);
196
+ [expectation fulfill ];
197
+ }];
198
+
138
199
[[[mock verify ] classMethod ] setEmailFieldRequiredForFeatureRequests: @(1 ) forAction: actions];
200
+ [self waitForExpectationsWithTimeout: kTimeout handler: nil ];
139
201
}
140
202
141
203
0 commit comments