Skip to content

Commit 49e2815

Browse files
committed
test TwitterUserFieldsV2
1 parent b69c6f3 commit 49e2815

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Sources/TwitterAPIKit/APIv2/FieldsV2.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public enum TwitterUserFieldsV2: TwitterAPIv2RequestParameter, Hashable {
9898
case username
9999
case verified
100100
case withheld
101+
case other(String)
101102

102103
public var stringValue: String {
103104
switch self {
@@ -129,6 +130,8 @@ public enum TwitterUserFieldsV2: TwitterAPIv2RequestParameter, Hashable {
129130
return "verified"
130131
case .withheld:
131132
return "withheld"
133+
case .other(let other):
134+
return other
132135
}
133136
}
134137
}

Tests/TwitterAPIKitTests/APIv2/FieldsV2Tests.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import XCTest
55
class FieldsV2Tests: XCTestCase {
66

77
// https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet
8+
// Select Model -> Select Table in Dev tool -> exec ↓ code
89
// [...$0.rows].slice(1).map(tr => { return tr.cells[0].textContent.replace("(default)", "").trim()}).sort().join(",")
910

1011
override func setUpWithError() throws {
@@ -44,4 +45,29 @@ class FieldsV2Tests: XCTestCase {
4445
"attachments,author_id,context_annotations,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,non_public_metrics,organic_metrics,possibly_sensitive,promoted_metrics,public_metrics,referenced_tweets,reply_settings,source,text,withheld,~~~"
4546
)
4647
}
48+
49+
func testTwitterUserFieldsV2() throws {
50+
let allCases: [TwitterUserFieldsV2] = [
51+
.createdAt,
52+
.description,
53+
.entities,
54+
.id,
55+
.location,
56+
.name,
57+
.pinnedTweetID,
58+
.profileImageUrl,
59+
.protected,
60+
.publicMetrics,
61+
.url,
62+
.username,
63+
.verified,
64+
.withheld,
65+
.other("~~"),
66+
]
67+
68+
XCTAssertEqual(
69+
allCases.commaSeparatedString,
70+
"created_at,description,entities,id,location,name,pinned_tweet_id,profile_image_url,protected,public_metrics,url,username,verified,withheld,~~"
71+
)
72+
}
4773
}

0 commit comments

Comments
 (0)