Skip to content

Commit

Permalink
add twiml tests
Browse files Browse the repository at this point in the history
  • Loading branch information
twof committed Jan 18, 2019
1 parent c932d51 commit 721e35e
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 50 deletions.
36 changes: 0 additions & 36 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,6 @@
"version": "1.3.1"
}
},
{
"package": "Fluent",
"repositoryURL": "https://github.com/vapor/fluent.git",
"state": {
"branch": null,
"revision": "00b81a9362549facb8e2ac93b17d2a78599fce3b",
"version": "3.1.2"
}
},
{
"package": "FluentSQLite",
"repositoryURL": "https://github.com/vapor/fluent-sqlite.git",
"state": {
"branch": null,
"revision": "c32f5bda84bf4ea691d19afe183d40044f579e11",
"version": "3.0.0"
}
},
{
"package": "HTTP",
"repositoryURL": "https://github.com/vapor/http.git",
Expand Down Expand Up @@ -91,24 +73,6 @@
"version": "1.0.0"
}
},
{
"package": "SQL",
"repositoryURL": "https://github.com/vapor/sql.git",
"state": {
"branch": null,
"revision": "839cf96eba296d26151ff1d7a746e9fe35053584",
"version": "2.2.0"
}
},
{
"package": "SQLite",
"repositoryURL": "https://github.com/vapor/sqlite.git",
"state": {
"branch": null,
"revision": "ad2e9bc9f0ed00ef2c6a05f89c1cec605467c90f",
"version": "3.1.0"
}
},
{
"package": "swift-nio",
"repositoryURL": "https://github.com/apple/swift-nio.git",
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ let package = Package(
.target(name: "Twilio", dependencies: ["Vapor"]),
.target(name: "App", dependencies: ["Vapor", "Twilio"]),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: ["App"])
.testTarget(name: "AppTests", dependencies: ["Twilio"])
]
)
13 changes: 0 additions & 13 deletions Tests/AppTests/AppTests.swift

This file was deleted.

72 changes: 72 additions & 0 deletions Tests/AppTests/TWIMLTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import Twilio
import XCTest

final class TWIMLTests: XCTestCase {
func testSMSResponse() throws {
let smsResponse = SMSResponse()

let expectedTwiml = """
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
</Response>
"""

XCTAssertEqual(smsResponse.generateTwiml(), expectedTwiml)
}

func testMessage() throws {
let message = Message(body: "Hello!")
let expectedTwiml = """
<Message>
<Body>
Hello!
</Body>
</Message>
"""

XCTAssertEqual(message.generateTwiml(), expectedTwiml)
}

func testSMSResponseWithSingleMessage() throws {
let message = Message(body: "Hello!")
let smsResponseWithMessage = SMSResponse(message)

let expectedTwiml = """
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Message>
<Body>
Hello!
</Body>
</Message>
</Response>
"""

XCTAssertEqual(smsResponseWithMessage.generateTwiml(), expectedTwiml)
}

func testSMSResponseWithMultipleMessages() throws {
let message = Message(body: "Hello")
let otherMessage = Message(body: "world!")
let smsResponseWithMessage = SMSResponse(message, otherMessage)

let expectedTwiml = """
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Message>
<Body>
Hello
</Body>
</Message>
<Message>
<Body>
world!
</Body>
</Message>
</Response>
"""

XCTAssertEqual(smsResponseWithMessage.generateTwiml(), expectedTwiml)
}
}

0 comments on commit 721e35e

Please sign in to comment.