Browse Source

Checks Faild

Jack 4 years ago
parent
commit
b0b300fbf7
1 changed files with 12 additions and 14 deletions
  1. 12 14
      Tests/KingfisherTests/ImageDownloaderTests.swift

+ 12 - 14
Tests/KingfisherTests/ImageDownloaderTests.swift

@@ -550,9 +550,18 @@ class ImageDownloaderTests: XCTestCase {
     
     
     
     
     func testSessionDelegate() {
     func testSessionDelegate() {
-        let extensionDelegate = ExtensionDelegate(expectation(description: #function))
-        downloader.sessionDelegate = extensionDelegate
-
+        class ExtensionDelegate:SessionDelegate {
+            //'exp' only for test
+            public let exp:XCTestExpectation
+            init(_ expectation:XCTestExpectation) {
+                exp = expectation
+            }
+            func urlSession(_ session: URLSession, task: URLSessionTask, didFinishCollecting metrics: URLSessionTaskMetrics) {
+                exp.fulfill()
+            }
+        }
+        downloader.sessionDelegate = ExtensionDelegate(expectation(description: #function))
+        
         let url = testURLs[0]
         let url = testURLs[0]
         stub(url, data: testImageData)
         stub(url, data: testImageData)
         downloader.downloadImage(with: url) { result in
         downloader.downloadImage(with: url) { result in
@@ -562,17 +571,6 @@ class ImageDownloaderTests: XCTestCase {
     }
     }
 }
 }
 
 
-class ExtensionDelegate:SessionDelegate {
-    //'exp' only for test
-    public let exp:XCTestExpectation
-    init(_ expectation:XCTestExpectation) {
-        exp = expectation
-    }
-    func urlSession(_ session: URLSession, task: URLSessionTask, didFinishCollecting metrics: URLSessionTaskMetrics) {
-        exp.fulfill()
-    }
-}
-
 extension ImageDownloaderTests: ImageDownloaderDelegate {
 extension ImageDownloaderTests: ImageDownloaderDelegate {
     func imageDownloader(_ downloader: ImageDownloader, didDownload data: Data, for url: URL) -> Data? {
     func imageDownloader(_ downloader: ImageDownloader, didDownload data: Data, for url: URL) -> Data? {
         return nil
         return nil