Browse Source

Add test for empty url

onevcat 10 năm trước cách đây
mục cha
commit
c662fd7420
1 tập tin đã thay đổi với 13 bổ sung0 xóa
  1. 13 0
      KingfisherTests/ImageDownloaderTests.swift

+ 13 - 0
KingfisherTests/ImageDownloaderTests.swift

@@ -206,4 +206,17 @@ class ImageDownloaderTests: XCTestCase {
         
         waitForExpectationsWithTimeout(5, handler: nil)
     }
+    
+    func testDownloadEmptyURL() {
+        let expectation = expectationWithDescription("wait for downloading error")
+        
+        downloader.downloadImageWithURL(NSURL(string: "")!, progressBlock: { (receivedSize, totalSize) -> () in
+            XCTFail("The progress block should not be called.")
+            }) { (image, error, imageURL, originalData) -> () in
+                XCTAssertNotNil(error, "An error should happen for empty URL")
+                XCTAssertEqual(error!.code, KingfisherError.InvalidURL.rawValue)
+                expectation.fulfill()
+        }
+        waitForExpectationsWithTimeout(5, handler: nil)
+    }
 }