forked from ZekeSnider/Jared
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
1bd394d
commit 099e2f5
Showing
11 changed files
with
102 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Pods/* linguist-vendored=true | ||
Pods/* linguist-vendored |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// MessageTests.swift | ||
// JaredTests | ||
// | ||
// Created by Zeke Snider on 2/3/19. | ||
// Copyright © 2019 Zeke Snider. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
import JaredFramework | ||
|
||
|
||
|
||
|
||
class MessageTests: XCTestCase { | ||
let textBody = TextBody("Hey Jared") | ||
|
||
let jaredPerson = Person(givenName: "jared", handle: "[email protected]", isMe: false, inGroup: nil) | ||
let mePerson = Person(givenName: "zeke", handle: "[email protected]", isMe: true, inGroup: nil) | ||
let swiftPerson = Person(givenName: "taylor", handle: "[email protected]", isMe: false, inGroup: nil) | ||
|
||
var sampleGroup: Group! | ||
|
||
var sampleTextMessage: Message! | ||
var sampleImageMesage: Message! | ||
var messageFromMeToGroup: Message! | ||
var messageFromMeToPerson: Message! | ||
var messageFromPersonToGroup: Message! | ||
|
||
override func setUp() { | ||
sampleGroup = Group(name: "thank u next", handle: "chat1000", participants: [mePerson, jaredPerson, swiftPerson]) | ||
|
||
sampleTextMessage = Message(body: textBody, date: Date(), sender: mePerson, recipient: jaredPerson) | ||
sampleImageMesage = Message(body: ImageBody("/users/zeke/goodJaredImage.jpg"), date: Date(), sender: mePerson, recipient: jaredPerson) | ||
|
||
messageFromMeToGroup = Message(body: textBody, date: Date(), sender: mePerson, recipient: sampleGroup) | ||
messageFromPersonToGroup = Message(body: textBody, date: Date(), sender: swiftPerson, recipient: sampleGroup) | ||
messageFromMeToPerson = Message(body: textBody, date: Date(), sender: mePerson, recipient: swiftPerson) | ||
} | ||
|
||
override func tearDown() { | ||
} | ||
|
||
func testGetTextBody() { | ||
XCTAssert(sampleTextMessage.getTextBody() == "Hey Jared", "getTextBody returns proper string") | ||
XCTAssert(sampleImageMesage.getTextBody() == nil, "getTextBody returns nil for image body") | ||
} | ||
|
||
func testGetImageBody() { | ||
XCTAssert(sampleTextMessage.getImageBody() == nil, "getTextBody returns nil for text body") | ||
XCTAssert(sampleImageMesage.getImageBody() == "/users/zeke/goodJaredImage.jpg", "getTextBody returns proper path") | ||
} | ||
|
||
func testGetMessageResponse() { | ||
XCTAssert(sampleTextMessage.RespondTo() as? Person == jaredPerson, "Message from me to person responds to recipient") | ||
XCTAssert(messageFromMeToGroup.RespondTo() as? Group == sampleGroup, "Message from me to group responds to group") | ||
XCTAssert(messageFromPersonToGroup.RespondTo() as? Group == sampleGroup, "Message from person to group responds to group") | ||
XCTAssert(messageFromMeToPerson.RespondTo() as? Person == swiftPerson, "Message from me to person responds to person") | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,8 @@ import JaredFramework | |
class WebhookTests: XCTestCase { | ||
let WEBHOOK_TEST_URL = "https://github.com/zekesnider/jaredwebhook" | ||
let WEBHOOK_TEST_URL_TWO = "https://twitter.com/zekesnider/jaredwebhook" | ||
let MESSAGE_SERIALIZED = "{\"sender\":{\"handle\":\"zeke@email.com\",\"givenName\":\"zeke\",\"isMe\":true},\"recipient\":{\"handle\":\"jared@email.com\",\"givenName\":\"jared\",\"isMe\":false},\"body\":{\"message\":\"hello there jared\"}}" | ||
let SAMPLE_MESSAGE = Message(body: TextBody("hello there jared"), date: Date(), sender: Person(givenName: "zeke", handle: "[email protected]", isMe: true, inGroup: nil), recipient: Person(givenName: "jared", handle: "[email protected]", isMe: false, inGroup: nil)) | ||
let MESSAGE_SERIALIZED = "{\"body\":{\"message\":\"hello there jared\"},\"recipient\":{\"handle\":\"jared@email.com\",\"givenName\":\"jared\",\"isMe\":false},\"sender\":{\"handle\":\"zeke@email.com\",\"givenName\":\"zeke\",\"isMe\":true},\"date\":\"2017-05-17T22:57:21.000Z\"}" | ||
let SAMPLE_MESSAGE = Message(body: TextBody("hello there jared"), date: Date(timeIntervalSince1970: TimeInterval(1495061841)), sender: Person(givenName: "zeke", handle: "[email protected]", isMe: true, inGroup: nil), recipient: Person(givenName: "jared", handle: "[email protected]", isMe: false, inGroup: nil)) | ||
|
||
var config: URLSessionConfiguration! | ||
|
||
|
@@ -26,7 +26,7 @@ class WebhookTests: XCTestCase { | |
URLProtocolMock.matchedDataURLs = [] | ||
} | ||
|
||
func callsWithValidURLs() { | ||
func testvalidURLsCall() { | ||
// set up first call to webhook with one url | ||
let url = URL(string: WEBHOOK_TEST_URL) | ||
URLProtocolMock.testURLs = [url: Data(MESSAGE_SERIALIZED.utf8)] | ||
|
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