This repository has been archived by the owner on Dec 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #150 from pvzig/member-leave-join-events
Add support for member_joined_channel and member_left_channel events
- Loading branch information
Showing
10 changed files
with
149 additions
and
136 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
91 changes: 0 additions & 91 deletions
91
SlackKit.xcodeproj/xcshareddata/xcschemes/Robot or Not Bot.xcscheme
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
{ | ||
"type": "member_joined_channel", | ||
"user": "U0CJ1TWKX", | ||
"channel": "C0CHZA86Q", | ||
"channel_type": "C", | ||
"team": "T0CHZBU59", | ||
"inviter": "U123456789" | ||
} |
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,7 @@ | ||
{ | ||
"type": "member_left_channel", | ||
"user": "U0CJ5PC7L", | ||
"channel": "C0CJ25PDM", | ||
"channel_type": "C", | ||
"team": "T0CHZBU59" | ||
} |
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,63 @@ | ||
// | ||
// SKClientTests.swift | ||
// SlackKitTests | ||
// | ||
// Created by Peter Zignego on 3/5/19. | ||
// Copyright © 2019 Peter Zignego. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import SKClient | ||
|
||
final class SKClientTests: XCTestCase { | ||
|
||
static var rootPath: String { | ||
#if Xcode | ||
return Bundle(for: self).resourcePath! | ||
#else | ||
return "SlackKitTests/Resources" | ||
#endif | ||
} | ||
|
||
struct JSONData { | ||
static let rtm_start = try! Data(contentsOf: URL(fileURLWithPath: "\(rootPath)/rtm.start.json")) | ||
static let member_joined_channel = try! Data(contentsOf: URL(fileURLWithPath: "\(rootPath)/member_joined_channel.json")) | ||
static let member_left_channel = try! Data(contentsOf: URL(fileURLWithPath: "\(rootPath)/member_left_channel.json")) | ||
} | ||
|
||
static var allTests = [ | ||
("testMemberJoinedChannel", testMemberJoinedChannel), | ||
("testMemberLeftChannel", testMemberLeftChannel) | ||
] | ||
|
||
var client: Client! | ||
|
||
override func setUp() { | ||
client = Client() | ||
client.initialSetup(JSON: try! JSONSerialization.jsonObject(with: JSONData.rtm_start, options: []) as! [String: Any]) | ||
} | ||
|
||
func testMemberJoinedChannel() { | ||
let channelId = "C0CHZA86Q" | ||
let userId = "U0CJ1TWKX" | ||
let json = try! JSONSerialization.jsonObject(with: JSONData.member_joined_channel, options: []) as! [String: Any] | ||
client.memberJoinedChannel(Event(json)) | ||
if let contains = client.channels[channelId]?.members?.contains(userId) { | ||
XCTAssertTrue(contains) | ||
} else { | ||
XCTFail() | ||
} | ||
} | ||
|
||
func testMemberLeftChannel() { | ||
let channelId = "C0CJ25PDM" | ||
let userId = "U0CJ5PC7L" | ||
let json = try! JSONSerialization.jsonObject(with: JSONData.member_left_channel, options: []) as! [String: Any] | ||
client.memberLeftChannel(Event(json)) | ||
if let contains = client.channels[channelId]?.members?.contains(userId) { | ||
XCTAssertFalse(contains) | ||
} else { | ||
XCTFail() | ||
} | ||
} | ||
} |
Oops, something went wrong.