-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
133 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
Sources/StreamChat/Utils/InternetConnection/Error+InternetNotAvailable_Tests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// | ||
// Copyright © 2021 Stream.io Inc. All rights reserved. | ||
// | ||
|
||
@testable import StreamChat | ||
import XCTest | ||
|
||
final class ErrorInternetNotAvailable_Tests: XCTestCase { | ||
func test_errorIsNSURLErrorNotConnectedToInternet() throws { | ||
let error = NSError( | ||
domain: NSURLErrorDomain, | ||
code: NSURLErrorNotConnectedToInternet, | ||
userInfo: nil | ||
) | ||
|
||
XCTAssertTrue(error.isInternetOfflineError) | ||
} | ||
|
||
func test_errorIsNSPOSIXErrorDomain50() throws { | ||
let error = NSError( | ||
domain: NSPOSIXErrorDomain, | ||
code: 50, | ||
userInfo: nil | ||
) | ||
|
||
XCTAssertTrue(error.isInternetOfflineError) | ||
} | ||
|
||
func test_errorDomainIsNotOneOfInternetOfflineError() throws { | ||
let error = NSError( | ||
domain: "Some domain", | ||
code: 50, | ||
userInfo: nil | ||
) | ||
|
||
XCTAssertFalse(error.isInternetOfflineError) | ||
} | ||
|
||
func test_errorCodeIsNotOneOfInternetOfflineError() throws { | ||
let error = NSError( | ||
domain: NSURLErrorDomain, | ||
code: 50, | ||
userInfo: nil | ||
) | ||
|
||
XCTAssertFalse(error.isInternetOfflineError) | ||
} | ||
|
||
func test_websocketEngineErrorInternetIsOffline() throws { | ||
let error = WebSocketEngineError( | ||
reason: "", | ||
code: -1009, | ||
engineError: NSError( | ||
domain: NSURLErrorDomain, | ||
code: NSURLErrorNotConnectedToInternet, | ||
userInfo: nil | ||
) | ||
) | ||
|
||
XCTAssertTrue(error.isInternetOfflineError) | ||
} | ||
|
||
func test_websocketEngineErrorDomainIsNotInternetIsOffline() throws { | ||
let error = WebSocketEngineError( | ||
reason: "", | ||
code: 304, | ||
engineError: NSError( | ||
domain: "Some domain", | ||
code: NSURLErrorNotConnectedToInternet, | ||
userInfo: nil | ||
) | ||
) | ||
|
||
XCTAssertFalse(error.isInternetOfflineError) | ||
} | ||
|
||
func test_websocketEngineErrorCodeIsNotInternetIsOffline() throws { | ||
let error = WebSocketEngineError( | ||
reason: "", | ||
code: 304, | ||
engineError: NSError( | ||
domain: NSURLErrorDomain, | ||
code: 304, | ||
userInfo: nil | ||
) | ||
) | ||
|
||
XCTAssertFalse(error.isInternetOfflineError) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters