Skip to content

Commit f739715

Browse files
committed
add test cases
1 parent 70d59ea commit f739715

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Diff for: SocketIO-MacTests/SocketBasicPacketTest.swift

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ class SocketBasicPacketTest: XCTestCase {
3737
XCTAssertEqual(packet.packetString, expectedSendString)
3838
}
3939

40+
func testStringEmitWithQuotes() {
41+
let expectedSendString = "2[\"test\",\"\\\"hello world\\\"\"]"
42+
let sendData = ["test", "\"hello world\""]
43+
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
44+
45+
XCTAssertEqual(packet.packetString, expectedSendString)
46+
}
47+
4048
func testJSONEmit() {
4149
let expectedSendString = "2[\"test\",{\"test\":\"hello\",\"hello\":1,\"foobar\":true,\"null\":null}]"
4250
let sendData = ["test", ["foobar": true, "hello": 1, "test": "hello", "null": NSNull()]]

Diff for: SocketIO-MacTests/SocketSideEffectTest.swift

+11
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ class SocketSideEffectTest: XCTestCase {
7070
waitForExpectationsWithTimeout(3, handler: nil)
7171
}
7272

73+
func testHandleStringEventWithQuotes() {
74+
let expectation = expectationWithDescription("handled event")
75+
socket.on("test") {data, ack in
76+
XCTAssertEqual(data[0] as? String, "\"hello world\"")
77+
expectation.fulfill()
78+
}
79+
80+
socket.parseSocketMessage("2[\"test\",\"\\\"hello world\\\"\"]")
81+
waitForExpectationsWithTimeout(3, handler: nil)
82+
}
83+
7384
func testHandleOnceEvent() {
7485
let expectation = expectationWithDescription("handled event")
7586
socket.once("test") {data, ack in

0 commit comments

Comments
 (0)