diff options
author | lapinskijw <jlapinski.dev@gmail.com> | 2020-03-27 14:35:21 -0400 |
---|---|---|
committer | lapinskijw <jlapinski.dev@gmail.com> | 2020-03-27 14:35:21 -0400 |
commit | e09bd5caef4d8c43ea54b504ce2fb2bd2fdb1ff3 (patch) | |
tree | 9b9f901391cdb0f925ae4ee0ec4f13b6abd3afe3 /SmartDeviceLinkTests/SDLCacheFileManagerSpec.m | |
parent | 62cfa07a9938ab31d955b8457805749dee7031fa (diff) | |
download | sdl_ios-e09bd5caef4d8c43ea54b504ce2fb2bd2fdb1ff3.tar.gz |
wrote failing test for downloading image
Diffstat (limited to 'SmartDeviceLinkTests/SDLCacheFileManagerSpec.m')
-rw-r--r-- | SmartDeviceLinkTests/SDLCacheFileManagerSpec.m | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/SmartDeviceLinkTests/SDLCacheFileManagerSpec.m b/SmartDeviceLinkTests/SDLCacheFileManagerSpec.m index ef4f3a08b..907123bce 100644 --- a/SmartDeviceLinkTests/SDLCacheFileManagerSpec.m +++ b/SmartDeviceLinkTests/SDLCacheFileManagerSpec.m @@ -122,27 +122,42 @@ describe(@"a cache file manager", ^{ __block UIImage *resultImage = nil; __block NSError *resultError = nil; - beforeEach(^{ - OCMStub(ClassMethod([mockArchiver archiveRootObject:[OCMArg any] toFile:[OCMArg any]])).andReturn(YES); + context(@"download succeeds", ^{ + beforeEach(^{ - OCMStub(ClassMethod([testManagerMock sdl_writeImage:[OCMArg any] toFileFromURL:[OCMArg any] atFilePath:[OCMArg any]])).andReturn(testFilePath); + OCMStub(ClassMethod([mockArchiver archiveRootObject:[OCMArg any] toFile:[OCMArg any]])).andReturn(YES); + OCMStub(ClassMethod([testManagerMock sdl_writeImage:[OCMArg any] toFileFromURL:[OCMArg any] atFilePath:[OCMArg any]])).andReturn(testFilePath); - // to do delete -// OCMStub([mockDataTask dataTaskWithURL:[OCMArg any] completionHandler:([OCMArg invokeBlockWithArgs:UIImagePNGRepresentation(testImage), blankResponse, [NSNull null], nil])]); + OCMStub([testManagerMock sdl_downloadIconFromRequestURL:[OCMArg any] withCompletionHandler:([OCMArg invokeBlockWithArgs:testImage, [NSNull null], nil])]); - OCMStub([testManagerMock sdl_downloadIconFromRequestURL:[OCMArg any] withCompletionHandler:([OCMArg invokeBlockWithArgs:testImage, [NSNull null], nil])]); + [testManager retrieveImageForRequest:expiredTestRequest withCompletionHandler:^(UIImage * _Nullable image, NSError * _Nullable error) { + resultImage = image; + resultError = error; + }]; + }); - [testManager retrieveImageForRequest:expiredTestRequest withCompletionHandler:^(UIImage * _Nullable image, NSError * _Nullable error) { - resultImage = image; - resultError = error; - }]; + it(@"it should return downloaded image and no error", ^{ + expect(resultImage).to(equal(testImage)); + expect(resultError).to(beNil()); + }); }); - it(@"it should return downloaded image and no error", ^{ - expect(resultImage).to(equal(testImage)); - expect(resultError).to(beNil()); - }); + context(@"download fails", ^{ + beforeEach(^{ + OCMStub([testManagerMock sdl_downloadIconFromRequestURL:[OCMArg any] withCompletionHandler:([OCMArg invokeBlockWithArgs:[NSNull null], [OCMArg any], nil])]); + [testManager retrieveImageForRequest:expiredTestRequest withCompletionHandler:^(UIImage * _Nullable image, NSError * _Nullable error) { + resultImage = image; + resultError = error; + }]; + }); + + it(@"it should return downloaded image and no error", ^{ + expect(resultImage).to(beNil()); + expect(resultError).toNot(beNil()); + }); + + }); }); }); @@ -246,9 +261,13 @@ describe(@"a cache file manager", ^{ expect(resultError).to(beNil()); }); }); - }); }); + + describe(@"Icon fails to download", ^{ + + }); + }); QuickSpecEnd |