@@ -4,16 +4,11 @@ import XCTest
44
55class FieldsV2Tests : XCTestCase {
66
7- // https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet
8- // Select Model -> Select Table in Dev tool -> exec ↓ code
9- // [...$0.rows].slice(1).map(tr => { return tr.cells[0].textContent.replace("(default)", "").trim()}).sort().join(",")
10-
117 override func setUpWithError( ) throws {
128 }
139
1410 override func tearDownWithError( ) throws {
1511 }
16-
1712 func testTwitterTweetFieldsV2( ) throws {
1813
1914 let allCases : [ TwitterTweetFieldsV2 ] = [
@@ -40,6 +35,7 @@ class FieldsV2Tests: XCTestCase {
4035 . other( " ~~~ " ) ,
4136 ] . shuffled ( )
4237
38+ // curl https://api.twitter.com/2/openapi.json | jq '.components.parameters.TweetFieldsParameter.schema.items.enum | sort | join(",")'
4339 XCTAssertEqual (
4440 allCases. commaSeparatedString,
4541 " 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,~~~ "
@@ -65,6 +61,7 @@ class FieldsV2Tests: XCTestCase {
6561 . other( " ~~ " ) ,
6662 ] . shuffled ( )
6763
64+ // curl https://api.twitter.com/2/openapi.json | jq '.components.parameters.UserFieldsParameter.schema.items.enum | sort | join(",")'
6865 XCTAssertEqual (
6966 allCases. commaSeparatedString,
7067 " created_at,description,entities,id,location,name,pinned_tweet_id,profile_image_url,protected,public_metrics,url,username,verified,withheld,~~ "
@@ -84,6 +81,7 @@ class FieldsV2Tests: XCTestCase {
8481 . other( " ~~~ " ) ,
8582 ] . shuffled ( )
8683
84+ // curl https://api.twitter.com/2/openapi.json | jq '.components.parameters.PlaceFieldsParameter.schema.items.enum | sort | join(",")'
8785 XCTAssertEqual (
8886 allCases. commaSeparatedString,
8987 " contained_within,country,country_code,full_name,geo,id,name,place_type,~~~ "
@@ -100,6 +98,7 @@ class FieldsV2Tests: XCTestCase {
10098 . other( " ~~ " ) ,
10199 ] . shuffled ( )
102100
101+ // curl https://api.twitter.com/2/openapi.json | jq '.components.parameters.PollFieldsParameter.schema.items.enum | sort | join(",")'
103102 XCTAssertEqual (
104103 allCases. commaSeparatedString,
105104 " duration_minutes,end_datetime,id,options,voting_status,~~ "
@@ -124,6 +123,8 @@ class FieldsV2Tests: XCTestCase {
124123
125124 ] . shuffled ( )
126125
126+ // curl https://api.twitter.com/2/openapi.json | jq '.components.parameters.MediaFieldsParameter.schema.items.enum | sort | join(",")'
127+
127128 // Note: `url` is missing in https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/media
128129 // https://twittercommunity.com/t/documentation-for-media-object-missing-url-field/163062
129130 XCTAssertEqual (
@@ -139,14 +140,17 @@ class FieldsV2Tests: XCTestCase {
139140 . memberCount,
140141 . `private`,
141142 . description,
143+ . id,
144+ . name,
142145 . ownerID,
143146 . other( " ~ " ) ,
144147 ] . shuffled ( )
145148
146- // id and name are not included because they are default.
149+ // curl https://api.twitter.com/2/openapi.json | jq '.components.parameters.ListFieldsParameter.schema.items.enum | sort | join(",")'
150+
147151 XCTAssertEqual (
148152 allCases. commaSeparatedString,
149- " created_at,description,follower_count,member_count,owner_id,private,~ "
153+ " created_at,description,follower_count,id, member_count,name ,owner_id,private,~ "
150154 )
151155 }
152156
0 commit comments