Quellcode durchsuchen

Add test for empty url

onevcat vor 10 Jahren
Ursprung
Commit
c662fd7420
1 geänderte Dateien mit 13 neuen und 0 gelöschten Zeilen
  1. 13 0
      KingfisherTests/ImageDownloaderTests.swift

+ 13 - 0
KingfisherTests/ImageDownloaderTests.swift

@@ -206,4 +206,17 @@ class ImageDownloaderTests: XCTestCase {
         
         
         waitForExpectationsWithTimeout(5, handler: nil)
         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)
+    }
 }
 }