Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reactions option in activity endpoint #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add unit test to cover the request parmeter
  • Loading branch information
homerzhm committed Nov 17, 2022
commit 69a158718c6e1da316c87b593fa5cf8e540e64c9
37 changes: 36 additions & 1 deletion Tests/Core/ClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,45 @@ final class ClientTests: TestCase {
}

func testActivityBaseURL() {
let endpoint = ActivityEndpoint<SimpleActivity>.getByIds(true, [.test1])
let endpoint = ActivityEndpoint<SimpleActivity>.getByIds(true, [.test1], [])
XCTAssertEqual(endpoint.baseURL, BaseURL.placeholderURL)
}

func testActivityWithReactionOption() {
var endpoint = ActivityEndpoint<SimpleActivity>.getByIds(true, [.test1], [.all])
switch endpoint.task {
case .requestParameters(let parameter, _):
XCTAssertEqual(parameter[ActivityEndpointParameters.ids.rawValue] as? String, .test1)
XCTAssertEqual(parameter[ActivityEndpointParameters.withRecentReactions.rawValue] as? Bool, true)
XCTAssertEqual(parameter[ActivityEndpointParameters.withOwnReactions.rawValue] as? Bool, true)
XCTAssertEqual(parameter[ActivityEndpointParameters.withReactionCounts.rawValue] as? Bool, true)
default:
XCTFail("Should be request parameter")
}

endpoint = ActivityEndpoint<SimpleActivity>.getByIds(true, [.test1], [.counts])
switch endpoint.task {
case .requestParameters(let parameter, _):
XCTAssertEqual(parameter[ActivityEndpointParameters.ids.rawValue] as? String, .test1)
XCTAssertNil(parameter[ActivityEndpointParameters.withRecentReactions.rawValue])
XCTAssertNil(parameter[ActivityEndpointParameters.withOwnReactions.rawValue] )
XCTAssertEqual(parameter[ActivityEndpointParameters.withReactionCounts.rawValue] as? Bool, true)
default:
XCTFail("Should be request parameter")
}

endpoint = ActivityEndpoint<SimpleActivity>.getByIds(true, [.test1], [.counts, .latest])
switch endpoint.task {
case .requestParameters(let parameter, _):
XCTAssertEqual(parameter[ActivityEndpointParameters.ids.rawValue] as? String, .test1)
XCTAssertEqual(parameter[ActivityEndpointParameters.withRecentReactions.rawValue] as? Bool, true)
XCTAssertNil(parameter[ActivityEndpointParameters.withOwnReactions.rawValue])
XCTAssertEqual(parameter[ActivityEndpointParameters.withReactionCounts.rawValue] as? Bool, true)
default:
XCTFail("Should be request parameter")
}
}

func testClientActivityGetByIds() {
expect("get an enriched activity by id") { test in
Client.shared.get(enrich: true, typeOf: Activity.self, activityIds: [.test1, .test2]) { result in
Expand Down