Skip to content

Commit

Permalink
tests too
Browse files Browse the repository at this point in the history
  • Loading branch information
daytime-em committed Apr 2, 2024
1 parent eafacd6 commit 144f8e6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Example/DemoAppTests/MuxImaListener_Test.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,24 @@ @interface MuxMockImaAdEvent : IMAAdEvent {
enum IMAAdEventType type;
}
@property (nonatomic) enum IMAAdEventType type;
@property(nonatomic, copy, nullable) NSDictionary<NSString *, id> *adData;
@end

@implementation MuxMockImaAdEvent

@synthesize type;
@synthesize adData;

- (id)initWithType:(NSInteger)_type {
type = _type;
return self;
}

- (id)initWithType:(NSInteger)_type andAdData:(NSDictionary*)_adData {
type = _type;
adData = _adData;
return self;
}
@end

SpecBegin(InitialSpecs)
Expand Down Expand Up @@ -118,6 +126,26 @@ - (id)initWithType:(NSInteger)_type {
MUXSDKPlaybackEvent *playbackEvent = [imaListener dispatchEvent:adEvent];
expect(playbackEvent).to.beKindOf([MUXSDKAdPauseEvent class]);
});

it(@"should not dispatch aderror for LOG event *without* error info", ^{
MuxMockImaAdEvent *adEvent = [[MuxMockImaAdEvent alloc] initWithType:kIMAAdEvent_LOG];
MUXSDKPlaybackEvent *playbackEvent = [imaListener dispatchEvent:adEvent];
expect(playbackEvent).to.beNil();
});

it(@"should dispatch aderror for LOG event with error info", ^{
NSMutableDictionary *mockErrorData = [[NSMutableDictionary alloc] init];
[mockErrorData setObject:[NSNumber numberWithInt:110] forKey:@"errorCode"];
[mockErrorData setObject:@"mock message" forKey:@"errorMessage"];
[mockErrorData setObject:@"adPlayError" forKey:@"type"];
NSMutableDictionary *mockLogData = [[NSMutableDictionary alloc] init];
[mockLogData setObject:mockErrorData forKey:@"logData"];

MuxMockImaAdEvent *adEvent = [[MuxMockImaAdEvent alloc] initWithType:kIMAAdEvent_LOG andAdData:mockLogData];

MUXSDKPlaybackEvent *playbackEvent = [imaListener dispatchEvent:adEvent];
expect(playbackEvent).to.beKindOf([MUXSDKAdErrorEvent class]);
});

it(@"should not dispatch an event for kIMAAdEvent_TAPPED", ^{
MuxMockImaAdEvent *adEvent = [[MuxMockImaAdEvent alloc] initWithType:kIMAAdEvent_TAPPED];
Expand Down

0 comments on commit 144f8e6

Please sign in to comment.