Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
Add TagsAPIFactoryTests
Browse files Browse the repository at this point in the history
  • Loading branch information
otaviocc committed Jan 9, 2022
1 parent dd0fe39 commit 2cd0eab
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/PinboardKit/API/TagsAPIFactory.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import MicroClient

public enum PinboardAPI {
public enum TagsAPIFactory {

/// Returns a full list of the user's tags along with the number of
/// times they were used.
Expand Down
85 changes: 85 additions & 0 deletions Tests/PinboardKitTests/TagsAPIFactoryTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import XCTest
import PinboardKit

class TagsAPIFactoryTests: XCTestCase {

func testMakeGetRequest() throws {
let request = TagsAPIFactory.makeGetRequest()

XCTAssertEqual(
request.path, "/v1/tags/get"
)

XCTAssertEqual(
request.method,
.get
)

XCTAssertNil(request.body)
XCTAssertNil(request.decoder)
XCTAssertNil(request.encoder)
}

func testMakeDeleteRequest() throws {
let request = TagsAPIFactory.makeDeleteRequest(
tag: "foobar"
)

XCTAssertEqual(
request.path, "/v1/tags/delete"
)

XCTAssertEqual(
request.method,
.get
)

XCTAssertTrue(
try XCTUnwrap(
request.queryItems?.contains(
URLQueryItem(name: "tag", value: "foobar")
)
)
)

XCTAssertNil(request.body)
XCTAssertNil(request.decoder)
XCTAssertNil(request.encoder)
}

func testMakeRenameRequest() throws {
let request = TagsAPIFactory.makeRenameRequest(
old: "old_name",
new: "new_name"
)

XCTAssertEqual(
request.path, "/v1/tags/rename"
)

XCTAssertEqual(
request.method,
.get
)

XCTAssertTrue(
try XCTUnwrap(
request.queryItems?.contains(
URLQueryItem(name: "new", value: "new_name")
)
)
)

XCTAssertTrue(
try XCTUnwrap(
request.queryItems?.contains(
URLQueryItem(name: "old", value: "old_name")
)
)
)

XCTAssertNil(request.body)
XCTAssertNil(request.decoder)
XCTAssertNil(request.encoder)
}
}
2 changes: 1 addition & 1 deletion Tests/PinboardKitTests/UpdateAPIFactoryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PinboardKit

final class UpdateAPIFactoryTests: XCTestCase {

func testMakeCheckFollowingRequest() throws {
func testMakeUpdateRequest() throws {
let request = UpdateAPIFactory.makeUpdateRequest()

XCTAssertEqual(
Expand Down

0 comments on commit 2cd0eab

Please sign in to comment.