|
| 1 | +// |
| 2 | +// instabug_flutter_exampleTests.m |
| 3 | +// instabug_flutter_exampleTests |
| 4 | +// |
| 5 | +// Created by Aly Ezz on 4/30/19. |
| 6 | +// Copyright © 2019 The Chromium Authors. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +#import <XCTest/XCTest.h> |
| 10 | +#import "OCMock/OCMock.h" |
| 11 | +#import "InstabugFlutterPlugin.h" |
| 12 | + |
| 13 | +@interface instabug_flutter_exampleTests : XCTestCase |
| 14 | + |
| 15 | +@end |
| 16 | + |
| 17 | +@implementation instabug_flutter_exampleTests |
| 18 | + |
| 19 | +- (void)testShowWelcomeMessageWithMode { |
| 20 | + id mock = OCMClassMock([InstabugFlutterPlugin class]); |
| 21 | + InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc] init]; |
| 22 | + id result; |
| 23 | + |
| 24 | + NSArray *arguments = [NSArray arrayWithObjects:@"WelcomeMessageMode.live", nil]; |
| 25 | + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"showWelcomeMessageWithMode:" arguments:arguments]; |
| 26 | + [[[mock stub] classMethod] showWelcomeMessageWithMode:@"WelcomeMessageMode.live"]; |
| 27 | + [instabug handleMethodCall:call result:result]; |
| 28 | + [[[mock verify] classMethod] showWelcomeMessageWithMode:@"WelcomeMessageMode.live"]; |
| 29 | +} |
| 30 | + |
| 31 | +- (void)testIdentifyUserWithEmail { |
| 32 | + id mock = OCMClassMock([InstabugFlutterPlugin class]); |
| 33 | + InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc] init]; |
| 34 | + id result; |
| 35 | + |
| 36 | + NSArray *arguments = [ NSArray arrayWithObjects:@"[email protected]", @"name", nil]; |
| 37 | + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"identifyUserWithEmail:name:" arguments:arguments]; |
| 38 | + [[[mock stub] classMethod] identifyUserWithEmail:@"[email protected]"name:@"name"]; |
| 39 | + [instabug handleMethodCall:call result:result]; |
| 40 | + [[[mock verify] classMethod] identifyUserWithEmail:@"[email protected]"name:@"name"]; |
| 41 | +} |
| 42 | + |
| 43 | +- (void)testLogOut { |
| 44 | + id mock = OCMClassMock([InstabugFlutterPlugin class]); |
| 45 | + InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc] init]; |
| 46 | + id result; |
| 47 | + |
| 48 | + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"logOut" arguments:NULL]; |
| 49 | + [[[mock stub] classMethod] logOut]; |
| 50 | + [instabug handleMethodCall:call result:result]; |
| 51 | + [[[mock verify] classMethod] logOut]; |
| 52 | +} |
| 53 | + |
| 54 | +- (void)testAppendTags { |
| 55 | + id mock = OCMClassMock([InstabugFlutterPlugin class]); |
| 56 | + InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc] init]; |
| 57 | + id result; |
| 58 | + |
| 59 | + NSArray *tags = [NSArray arrayWithObjects:@"tag1", @"tag2", nil]; |
| 60 | + NSArray *arguments = [NSArray arrayWithObjects: tags, nil]; |
| 61 | + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"appendTags:" arguments:arguments]; |
| 62 | + [[[mock stub] classMethod] appendTags:tags]; |
| 63 | + [instabug handleMethodCall:call result:result]; |
| 64 | + [[[mock verify] classMethod] appendTags:tags]; |
| 65 | +} |
| 66 | + |
| 67 | +- (void)testInvokeWithMode { |
| 68 | + id mock = OCMClassMock([InstabugFlutterPlugin class]); |
| 69 | + InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc] init]; |
| 70 | + id result; |
| 71 | + |
| 72 | + NSArray *options = [NSArray arrayWithObjects:@"commentFieldRequired", @"disablePostSendingDialog", nil]; |
| 73 | + NSArray *arguments = [NSArray arrayWithObjects:@"bug", options, nil]; |
| 74 | + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"invokeWithMode:options:" arguments:arguments]; |
| 75 | + [[[mock stub] classMethod] invokeWithMode:@"bug"options:options]; |
| 76 | + [instabug handleMethodCall:call result:result]; |
| 77 | + [[[mock verify] classMethod] invokeWithMode:@"bug"options:options]; |
| 78 | +} |
| 79 | + |
| 80 | +- (void)testSetSessionProfilerEnabled { |
| 81 | + id mock = OCMClassMock([InstabugFlutterPlugin class]); |
| 82 | + InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc] init]; |
| 83 | + id result; |
| 84 | + |
| 85 | + NSArray *arguments = [NSArray arrayWithObjects:@(1), nil]; |
| 86 | + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"setSessionProfilerEnabled:" arguments:arguments]; |
| 87 | + [[[mock stub] classMethod] setSessionProfilerEnabled:@(1)]; |
| 88 | + [instabug handleMethodCall:call result:result]; |
| 89 | + [[[mock verify] classMethod] setSessionProfilerEnabled:@(1)]; |
| 90 | +} |
| 91 | + |
| 92 | +- (void)testSetPrimaryColor { |
| 93 | + id mock = OCMClassMock([InstabugFlutterPlugin class]); |
| 94 | + InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc] init]; |
| 95 | + id result; |
| 96 | + |
| 97 | + NSArray *arguments = [NSArray arrayWithObjects:@(1123123123121), nil]; |
| 98 | + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"setPrimaryColor:" arguments:arguments]; |
| 99 | + [[[mock stub] classMethod] setPrimaryColor:@(1123123123121)]; |
| 100 | + [instabug handleMethodCall:call result:result]; |
| 101 | + [[[mock verify] classMethod] setPrimaryColor:@(1123123123121)]; |
| 102 | +} |
| 103 | + |
| 104 | +- (void)testAddFileAttachmentWithData { |
| 105 | + id mock = OCMClassMock([InstabugFlutterPlugin class]); |
| 106 | + InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc] init]; |
| 107 | + id result; |
| 108 | + |
| 109 | + FlutterStandardTypedData *data; |
| 110 | + NSArray *arguments = [NSArray arrayWithObjects:data, nil]; |
| 111 | + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"addFileAttachmentWithData:" arguments:arguments]; |
| 112 | + [[[mock stub] classMethod] addFileAttachmentWithData:data]; |
| 113 | + [instabug handleMethodCall:call result:result]; |
| 114 | + [[[mock verify] classMethod] addFileAttachmentWithData:data]; |
| 115 | +} |
| 116 | + |
| 117 | +- (void)testSetEnabledAttachmentTypes { |
| 118 | + id mock = OCMClassMock([InstabugFlutterPlugin class]); |
| 119 | + InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc] init]; |
| 120 | + id result; |
| 121 | + |
| 122 | + NSArray *arguments = [NSArray arrayWithObjects:@(1),@(1),@(1),@(1), nil]; |
| 123 | + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"setEnabledAttachmentTypes:extraScreenShot:galleryImage:screenRecording:" arguments:arguments]; |
| 124 | + [[[mock stub] classMethod] setEnabledAttachmentTypes:@(1) extraScreenShot:@(1) galleryImage:@(1) screenRecording:@(1) ]; |
| 125 | + [instabug handleMethodCall:call result:result]; |
| 126 | + [[[mock verify] classMethod] setEnabledAttachmentTypes:@(1) extraScreenShot:@(1) galleryImage:@(1) screenRecording:@(1)]; |
| 127 | +} |
| 128 | + |
| 129 | +- (void)testSetEmailFieldRequiredForFeatureRequests { |
| 130 | + id mock = OCMClassMock([InstabugFlutterPlugin class]); |
| 131 | + InstabugFlutterPlugin *instabug = [[InstabugFlutterPlugin alloc] init]; |
| 132 | + id result; |
| 133 | + |
| 134 | + NSArray *actions = [NSArray arrayWithObjects:@"reportBug", @"requestNewFeature", nil]; |
| 135 | + NSArray *arguments = [NSArray arrayWithObjects:@(1), actions, nil]; |
| 136 | + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"setEmailFieldRequiredForFeatureRequests:forAction:" arguments:arguments]; |
| 137 | + [[[mock stub] classMethod] setEmailFieldRequiredForFeatureRequests:@(1) forAction:actions]; |
| 138 | + [instabug handleMethodCall:call result:result]; |
| 139 | + [[[mock verify] classMethod] setEmailFieldRequiredForFeatureRequests:@(1) forAction:actions]; |
| 140 | +} |
| 141 | + |
| 142 | + |
| 143 | +@end |
0 commit comments