add test for transport open calling connect
This commit is contained in:
parent
cd2454373a
commit
5c0bbde77b
@ -252,6 +252,7 @@ class SocketSideEffectTest: XCTestCase {
|
||||
let expect = expectation(description: "The client should call the timeout function")
|
||||
|
||||
socket.setTestStatus(.notConnected)
|
||||
socket.nsp = "/someNamespace"
|
||||
socket.engine = TestEngine(client: socket, url: socket.socketURL, options: nil)
|
||||
|
||||
socket.connect(timeoutAfter: 0.5, withHandler: {
|
||||
@ -283,6 +284,23 @@ class SocketSideEffectTest: XCTestCase {
|
||||
waitForExpectations(timeout: 2)
|
||||
}
|
||||
|
||||
func testClientCallsConnectOnEngineOpen() {
|
||||
let expect = expectation(description: "The client call the connect handler")
|
||||
|
||||
socket.setTestStatus(.notConnected)
|
||||
socket.engine = TestEngine(client: socket, url: socket.socketURL, options: nil)
|
||||
|
||||
socket.on(clientEvent: .connect) {data, ack in
|
||||
expect.fulfill()
|
||||
}
|
||||
|
||||
socket.connect(timeoutAfter: 0.5, withHandler: {
|
||||
XCTFail("Should not call timeout handler if status is connected")
|
||||
})
|
||||
|
||||
waitForExpectations(timeout: 2)
|
||||
}
|
||||
|
||||
func testConnectIsCalledWithNamespace() {
|
||||
let expect = expectation(description: "The client should not call the timeout function")
|
||||
let nspString = "/swift"
|
||||
@ -399,7 +417,7 @@ struct ThrowingData : SocketData {
|
||||
}
|
||||
|
||||
class TestEngine : SocketEngineSpec {
|
||||
var client: SocketEngineClient? = nil
|
||||
weak var client: SocketEngineClient?
|
||||
private(set) var closed = false
|
||||
private(set) var connected = false
|
||||
var connectParams: [String: Any]? = nil
|
||||
@ -418,9 +436,14 @@ class TestEngine : SocketEngineSpec {
|
||||
private(set) var websocket = false
|
||||
private(set) var ws: WebSocket? = nil
|
||||
|
||||
required init(client: SocketEngineClient, url: URL, options: NSDictionary?) { }
|
||||
required init(client: SocketEngineClient, url: URL, options: NSDictionary?) {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
func connect() {
|
||||
client?.engineDidOpen(reason: "Connect")
|
||||
}
|
||||
|
||||
func connect() { }
|
||||
func didError(reason: String) { }
|
||||
func disconnect(reason: String) { }
|
||||
func doFastUpgrade() { }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user