noblox-asset.js 7.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
  2. package/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
  3. package/.github/workflows/doc-publish.yml +33 -0
  4. package/.github/workflows/npmpublish.yml +72 -0
  5. package/.github/workflows/run-tests.yml +49 -0
  6. package/CODE_OF_CONDUCT.md +76 -0
  7. package/LICENSE +21 -0
  8. package/README.md +182 -0
  9. package/eslint.config.mjs +34 -0
  10. package/examples/cleanPlayers.js +130 -0
  11. package/examples/cleanWall.js +110 -0
  12. package/examples/revertRanks.js +100 -0
  13. package/examples/savePlayers.js +119 -0
  14. package/examples/saveWall.js +96 -0
  15. package/img/moderatedThumbnails/moderatedThumbnail_100x100.png +0 -0
  16. package/img/moderatedThumbnails/moderatedThumbnail_110x110.png +0 -0
  17. package/img/moderatedThumbnails/moderatedThumbnail_140x140.png +0 -0
  18. package/img/moderatedThumbnails/moderatedThumbnail_150x150.png +0 -0
  19. package/img/moderatedThumbnails/moderatedThumbnail_150x200.png +0 -0
  20. package/img/moderatedThumbnails/moderatedThumbnail_180x180.png +0 -0
  21. package/img/moderatedThumbnails/moderatedThumbnail_250x250.png +0 -0
  22. package/img/moderatedThumbnails/moderatedThumbnail_30x30.png +0 -0
  23. package/img/moderatedThumbnails/moderatedThumbnail_352x352.png +0 -0
  24. package/img/moderatedThumbnails/moderatedThumbnail_420x420.png +0 -0
  25. package/img/moderatedThumbnails/moderatedThumbnail_48x48.png +0 -0
  26. package/img/moderatedThumbnails/moderatedThumbnail_50x50.png +0 -0
  27. package/img/moderatedThumbnails/moderatedThumbnail_60x60.png +0 -0
  28. package/img/moderatedThumbnails/moderatedThumbnail_720x720.png +0 -0
  29. package/img/moderatedThumbnails/moderatedThumbnail_75x75.png +0 -0
  30. package/img/noblox-js-small.png +0 -0
  31. package/img/noblox-js.png +0 -0
  32. package/img/thumbnailSizes.png +0 -0
  33. package/jsDocsConfig.json +55 -0
  34. package/lib/accountinformation/getUserSocialLinks.js +40 -0
  35. package/lib/accountsettings/block.js +53 -0
  36. package/lib/accountsettings/unblock.js +53 -0
  37. package/lib/asset/deleteFromInventory.js +56 -0
  38. package/lib/asset/getGamePassProductInfo.js +50 -0
  39. package/lib/asset/getProductInfo.js +46 -0
  40. package/lib/asset/uploadAnimation.js +103 -0
  41. package/lib/asset/uploadItem.js +83 -0
  42. package/lib/asset/uploadModel.js +90 -0
  43. package/lib/avatar/avatarRules.js +39 -0
  44. package/lib/avatar/currentlyWearing.js +33 -0
  45. package/lib/avatar/getAvatar.js +36 -0
  46. package/lib/avatar/getCurrentAvatar.js +38 -0
  47. package/lib/avatar/getRecentItems.js +36 -0
  48. package/lib/avatar/outfitDetails.js +33 -0
  49. package/lib/avatar/outfits.js +38 -0
  50. package/lib/avatar/redrawAvatar.js +47 -0
  51. package/lib/avatar/removeAssetId.js +51 -0
  52. package/lib/avatar/setAvatarBodyColors.js +61 -0
  53. package/lib/avatar/setAvatarScales.js +61 -0
  54. package/lib/avatar/setPlayerAvatarType.js +51 -0
  55. package/lib/avatar/setWearingAssets.js +51 -0
  56. package/lib/avatar/wearAssetId.js +51 -0
  57. package/lib/badges/getAwardedTimestamps.js +49 -0
  58. package/lib/badges/getBadgeInfo.js +44 -0
  59. package/lib/badges/getGameBadges.js +63 -0
  60. package/lib/badges/getPlayerBadges.js +28 -0
  61. package/lib/badges/updateBadgeInfo.js +75 -0
  62. package/lib/cache/add.js +14 -0
  63. package/lib/cache/addIf.js +26 -0
  64. package/lib/cache/clear.js +8 -0
  65. package/lib/cache/get.js +28 -0
  66. package/lib/cache/index.js +17 -0
  67. package/lib/cache/new.js +12 -0
  68. package/lib/cache/wrap.js +25 -0
  69. package/lib/chat/addUsersToConversation.js +58 -0
  70. package/lib/chat/chatSettings.js +34 -0
  71. package/lib/chat/getChatMessages.js +41 -0
  72. package/lib/chat/getConversations.js +44 -0
  73. package/lib/chat/getRolloutSettings.js +36 -0
  74. package/lib/chat/getUnreadConversationCount.js +34 -0
  75. package/lib/chat/getUnreadMessages.js +39 -0
  76. package/lib/chat/getUserConversations.js +38 -0
  77. package/lib/chat/markChatAsRead.js +53 -0
  78. package/lib/chat/markChatAsSeen.js +51 -0
  79. package/lib/chat/multiGetLatestMessages.js +38 -0
  80. package/lib/chat/onNewConversation.js +50 -0
  81. package/lib/chat/onNewMessage.js +53 -0
  82. package/lib/chat/onNewMessageBySelf.js +50 -0
  83. package/lib/chat/onUserOnline.js +50 -0
  84. package/lib/chat/onUserTyping.js +54 -0
  85. package/lib/chat/removeFromGroupConversation.js +59 -0
  86. package/lib/chat/renameGroupConversation.js +58 -0
  87. package/lib/chat/sendChatMessage.js +58 -0
  88. package/lib/chat/setChatUserTyping.js +58 -0
  89. package/lib/chat/start121Conversation.js +51 -0
  90. package/lib/chat/startCloudEditConversation.js +51 -0
  91. package/lib/chat/startGroupConversation.js +59 -0
  92. package/lib/client/onNotification.js +86 -0
  93. package/lib/client/setAPIKey.js +18 -0
  94. package/lib/client/setCookie.js +38 -0
  95. package/lib/datastores/deleteDatastoreEntry.js +56 -0
  96. package/lib/datastores/getDatastoreEntry.js +88 -0
  97. package/lib/datastores/getDatastoreEntryVersions.js +73 -0
  98. package/lib/datastores/getDatastoreKeys.js +63 -0
  99. package/lib/datastores/getDatastores.js +62 -0
  100. package/lib/datastores/incrementDatastoreEntry.js +83 -0
  101. package/lib/datastores/setDatastoreEntry.js +80 -0
  102. package/lib/develop/canManage.js +42 -0
  103. package/lib/develop/configureItem.js +210 -0
  104. package/lib/develop/updateUniverse.js +52 -0
  105. package/lib/develop/updateUniverseAccess.js +54 -0
  106. package/lib/economy/getGroupFunds.js +42 -0
  107. package/lib/economy/getGroupPayoutEligibility.js +55 -0
  108. package/lib/economy/getGroupRevenueSummary.js +42 -0
  109. package/lib/economy/getGroupTransactions.js +32 -0
  110. package/lib/economy/getResaleData.js +48 -0
  111. package/lib/economy/getResellers.js +35 -0
  112. package/lib/economy/getUserFunds.js +43 -0
  113. package/lib/economy/getUserTransactions.js +34 -0
  114. package/lib/economy/onGroupTransaction.js +74 -0
  115. package/lib/friends/acceptFriendRequest.js +54 -0
  116. package/lib/friends/declineAllFriendRequests.js +52 -0
  117. package/lib/friends/declineFriendRequest.js +54 -0
  118. package/lib/friends/getFollowerCount.js +35 -0
  119. package/lib/friends/getFollowers.js +56 -0
  120. package/lib/friends/getFollowingCount.js +35 -0
  121. package/lib/friends/getFollowings.js +56 -0
  122. package/lib/friends/getFriendCount.js +35 -0
  123. package/lib/friends/getFriendRequests.js +51 -0
  124. package/lib/friends/getFriends.js +48 -0
  125. package/lib/friends/onFriendRequest.js +58 -0
  126. package/lib/friends/removeFriend.js +53 -0
  127. package/lib/friends/sendFriendRequest.js +54 -0
  128. package/lib/friends/unfollow.js +53 -0
  129. package/lib/games/addDeveloperProduct.js +53 -0
  130. package/lib/games/configureGamePass.js +126 -0
  131. package/lib/games/getDeveloperProducts.js +44 -0
  132. package/lib/games/getGameInstances.js +31 -0
  133. package/lib/games/getGamePasses.js +39 -0
  134. package/lib/games/getGameRevenue.js +48 -0
  135. package/lib/games/getGameSocialLinks.js +42 -0
  136. package/lib/games/getGroupGames.js +30 -0
  137. package/lib/games/getPlaceInfo.js +47 -0
  138. package/lib/games/getUniverseInfo.js +50 -0
  139. package/lib/games/publishToTopic.js +52 -0
  140. package/lib/games/sendUserNotification.js +65 -0
  141. package/lib/games/updateDeveloperProduct.js +56 -0
  142. package/lib/groups/banFromGroup.js +47 -0
  143. package/lib/groups/changeRank.js +59 -0
  144. package/lib/groups/deleteWallPost.js +59 -0
  145. package/lib/groups/deleteWallPostsByUser.js +55 -0
  146. package/lib/groups/demote.js +25 -0
  147. package/lib/groups/exile.js +55 -0
  148. package/lib/groups/getAuditLog.js +64 -0
  149. package/lib/groups/getGroup.js +50 -0
  150. package/lib/groups/getGroupBans.js +37 -0
  151. package/lib/groups/getGroupSocialLinks.js +41 -0
  152. package/lib/groups/getGroups.js +82 -0
  153. package/lib/groups/getJoinRequest.js +47 -0
  154. package/lib/groups/getJoinRequests.js +53 -0
  155. package/lib/groups/getPlayers.js +103 -0
  156. package/lib/groups/getRankInGroup.js +45 -0
  157. package/lib/groups/getRankNameInGroup.js +44 -0
  158. package/lib/groups/getRole.js +64 -0
  159. package/lib/groups/getRolePermissions.js +48 -0
  160. package/lib/groups/getRoles.js +53 -0
  161. package/lib/groups/getShout.js +47 -0
  162. package/lib/groups/getWall.js +56 -0
  163. package/lib/groups/groupPayout.js +103 -0
  164. package/lib/groups/handleJoinRequest.js +57 -0
  165. package/lib/groups/handleJoinRequests.js +61 -0
  166. package/lib/groups/leaveGroup.js +56 -0
  167. package/lib/groups/onAuditLog.js +62 -0
  168. package/lib/groups/onJoinRequest.js +63 -0
  169. package/lib/groups/onJoinRequestHandle.js +105 -0
  170. package/lib/groups/onShout.js +57 -0
  171. package/lib/groups/onWallPost.js +58 -0
  172. package/lib/groups/promote.js +25 -0
  173. package/lib/groups/searchGroups.js +32 -0
  174. package/lib/groups/setGroupDescription.js +58 -0
  175. package/lib/groups/setGroupName.js +59 -0
  176. package/lib/groups/setRank.js +74 -0
  177. package/lib/groups/setRoleInfo.js +84 -0
  178. package/lib/groups/shout.js +58 -0
  179. package/lib/groups/unbanFromGroup.js +41 -0
  180. package/lib/index.js +212 -0
  181. package/lib/internal/levelOneCopy.js +16 -0
  182. package/lib/internal/queue.js +61 -0
  183. package/lib/internal/timeout.js +30 -0
  184. package/lib/internal/wrap.js +78 -0
  185. package/lib/inventory/getCollectibles.js +31 -0
  186. package/lib/inventory/getInventory.js +32 -0
  187. package/lib/inventory/getInventoryById.js +31 -0
  188. package/lib/inventory/getOwnership.js +47 -0
  189. package/lib/inventory/getUAIDs.js +47 -0
  190. package/lib/itemconfiguration/getGroupAssets.js +32 -0
  191. package/lib/options.js +26 -0
  192. package/lib/party/onPartyDeleted.js +53 -0
  193. package/lib/party/onPartyInvite.js +53 -0
  194. package/lib/party/onPartyJoinedGame.js +53 -0
  195. package/lib/party/onPartyLeftGame.js +53 -0
  196. package/lib/party/onPartySelfJoined.js +53 -0
  197. package/lib/party/onPartySelfLeft.js +53 -0
  198. package/lib/party/onPartyUserJoined.js +53 -0
  199. package/lib/party/onPartyUserLeft.js +53 -0
  200. package/lib/premiumfeatures/getPremium.js +46 -0
  201. package/lib/presence/getPresences.js +60 -0
  202. package/lib/privatemessages/getMessages.js +55 -0
  203. package/lib/privatemessages/message.js +75 -0
  204. package/lib/privatemessages/onMessage.js +89 -0
  205. package/lib/thumbnails/getLogo.js +56 -0
  206. package/lib/thumbnails/getPlayerThumbnail.js +120 -0
  207. package/lib/thumbnails/getThumbnails.js +92 -0
  208. package/lib/trades/acceptTrade.js +52 -0
  209. package/lib/trades/canTradeWith.js +43 -0
  210. package/lib/trades/counterTrade.js +78 -0
  211. package/lib/trades/declineTrade.js +52 -0
  212. package/lib/trades/getTradeInfo.js +47 -0
  213. package/lib/trades/getTrades.js +37 -0
  214. package/lib/trades/sendTrade.js +76 -0
  215. package/lib/users/getBlurb.js +37 -0
  216. package/lib/users/getIdFromUsername.js +56 -0
  217. package/lib/users/getPlayerInfo.js +128 -0
  218. package/lib/users/getUserInfo.js +35 -0
  219. package/lib/users/getUsernameFromId.js +45 -0
  220. package/lib/users/getUsernameHistory.js +42 -0
  221. package/lib/users/onBlurbChange.js +46 -0
  222. package/lib/users/searchUsers.js +41 -0
  223. package/lib/util/apiError.js +50 -0
  224. package/lib/util/clearSession.js +32 -0
  225. package/lib/util/generalRequest.js +61 -0
  226. package/lib/util/getAction.js +45 -0
  227. package/lib/util/getAuthenticatedUser.js +41 -0
  228. package/lib/util/getCurrentUser.js +58 -0
  229. package/lib/util/getGeneralToken.js +52 -0
  230. package/lib/util/getHash.js +29 -0
  231. package/lib/util/getInputs.js +37 -0
  232. package/lib/util/getPageResults.js +86 -0
  233. package/lib/util/getSenderUserId.js +30 -0
  234. package/lib/util/getSession.js +38 -0
  235. package/lib/util/getVerification.js +60 -0
  236. package/lib/util/getVerificationInputs.js +31 -0
  237. package/lib/util/http.js +138 -0
  238. package/lib/util/jar.js +25 -0
  239. package/lib/util/refreshCookie.js +52 -0
  240. package/lib/util/relog.js +81 -0
  241. package/lib/util/setOptions.js +54 -0
  242. package/lib/util/shortPoll.js +102 -0
  243. package/package.json +76 -0
  244. package/postinstall.mjs +1 -0
  245. package/settings.json +115 -0
  246. package/test/accountinformation.test.js +27 -0
  247. package/test/accountsettings.test.js +27 -0
  248. package/test/asset.test.js +81 -0
  249. package/test/assets/Great-White-Shark-Fin.rbxm +0 -0
  250. package/test/assets/KeyframeSequence.rbxm +0 -0
  251. package/test/avatar.test.js +164 -0
  252. package/test/badges.test.js +96 -0
  253. package/test/chat.test.js +104 -0
  254. package/test/datastore.test.js +105 -0
  255. package/test/develop.test.js +53 -0
  256. package/test/economy.test.js +143 -0
  257. package/test/friends.test.js +146 -0
  258. package/test/games.test.js +229 -0
  259. package/test/groups.test.js +405 -0
  260. package/test/inventory.test.js +98 -0
  261. package/test/itemconfiguration.test.js +24 -0
  262. package/test/premiumfeatures.test.js +17 -0
  263. package/test/presence.test.js +25 -0
  264. package/test/privatemessages.test.js +33 -0
  265. package/test/thumbnails.test.js +53 -0
  266. package/test/users.test.js +110 -0
  267. package/tutorials/Authentication.md +75 -0
  268. package/tutorials/Event Emitters.md +26 -0
  269. package/tutorials/Promises.md +86 -0
  270. package/tutorials/VPS Authentication.md +72 -0
  271. package/typings/index.d.ts +2639 -0
  272. package/typings/jsDocs.ts +1987 -0
@@ -0,0 +1,229 @@
1
+ const { addDeveloperProduct, checkDeveloperProductName, getAuthenticatedUser, getGroupGames, configureGamePass, getGameInstances, getGamePasses, getGameSocialLinks, getUniverseInfo, sendUserNotification, setAPIKey, setCookie } = require('../lib')
2
+
3
+ beforeAll(() => {
4
+ setAPIKey(process.env.API_KEY)
5
+
6
+ return new Promise(resolve => {
7
+ setCookie(process.env.COOKIE).then(() => {
8
+ resolve()
9
+ })
10
+ })
11
+ })
12
+
13
+ describe('Game Methods', () => {
14
+ // let newProductId
15
+
16
+ it('addDeveloperProduct() adds a developer product to a universe', () => {
17
+ return addDeveloperProduct(79354837, `${parseInt(Date.now().toString().slice(-6))} Coins`, 5, 'A hefty sum of cash for you and a successful test for me.').then((res) => {
18
+ // newProductId = res.productId
19
+
20
+ return expect(res).toMatchObject({
21
+ universeId: 79354837,
22
+ name: expect.any(String), // account for Roblox filters
23
+ priceInRobux: 5,
24
+ description: expect.any(String), // account for Roblox filters
25
+ productId: expect.any(Number)
26
+ })
27
+ })
28
+ })
29
+
30
+ it('checkDeveloperProductName() should return if a developer product name is in use within a universe', () => {
31
+ return checkDeveloperProductName(79354837, '100 Koins').then((res) => {
32
+ return expect(res).toMatchObject({
33
+ Success: expect.any(Boolean),
34
+ Message: expect.any(String)
35
+ })
36
+ })
37
+ })
38
+
39
+ it('configureGamePass() should configure a game pass', () => {
40
+ const randomString = Date.now().toString().substr(-2)
41
+ return configureGamePass(13925030, `name${randomString}`, 'random description', parseInt(randomString)).then((res) => {
42
+ return expect(res).toMatchObject({
43
+ gamePassId: 13925030,
44
+ name: `name${randomString}`,
45
+ description: 'random description',
46
+ price: parseInt(randomString),
47
+ isForSale: true,
48
+ iconChanged: false
49
+ })
50
+ })
51
+ })
52
+
53
+ // Broken as of v4.14.0
54
+ // eslint-disable-next-line jest/no-commented-out-tests
55
+ // it('getDeveloperProducts() should return developer products, given placeId', () => {
56
+ // return getDeveloperProducts(166178819).then((res) => {
57
+ // return expect(res).toMatchObject({
58
+ // DeveloperProducts: expect.any(Array),
59
+ // FinalPage: expect.any(Boolean),
60
+ // PageSize: expect.any(Number)
61
+ // })
62
+ // })
63
+ // })
64
+
65
+ it('getGameInstances() should return instances of a game, given placeId', () => {
66
+ return getGameInstances(142823291, 'Public', 'Asc', 100).then((res) => {
67
+ return expect(res).toEqual(
68
+ expect.arrayContaining([
69
+ expect.objectContaining({
70
+ id: expect.any(String),
71
+ maxPlayers: expect.any(Number),
72
+ playing: expect.any(Number),
73
+ playerTokens: expect.arrayContaining([
74
+ expect.any(String)
75
+ ]),
76
+ fps: expect.any(Number),
77
+ ping: expect.any(Number)
78
+ })
79
+ ])
80
+ )
81
+ })
82
+ })
83
+
84
+ it('getGamePasses() should return an array of game passes, given universeId', () => {
85
+ return getGamePasses(2615802125).then((res) => {
86
+ return expect(res).toEqual(
87
+ expect.arrayContaining([
88
+ expect.objectContaining({
89
+ id: expect.any(Number),
90
+ name: expect.any(String),
91
+ displayName: expect.any(String),
92
+ productId: expect.any(Number),
93
+ price: expect.any(Number)
94
+ })
95
+ ])
96
+ )
97
+ })
98
+ })
99
+
100
+ it('getGameSocialLinks() should return social link information of a game, given universeId', () => {
101
+ return getGameSocialLinks(2615802125).then((res) => {
102
+ return expect(res).toEqual(
103
+ expect.arrayContaining([
104
+ expect.objectContaining({
105
+ id: expect.any(Number),
106
+ title: expect.any(String),
107
+ type: expect.any(String),
108
+ url: expect.any(String)
109
+ })
110
+ ])
111
+ )
112
+ })
113
+ })
114
+
115
+ it('getGroupGames() returns an array of group games', () => {
116
+ return getGroupGames({ groupId: 9997719, limit: 1 }).then((res) => {
117
+ return expect(res[0]).toMatchObject({
118
+ id: expect.any(Number),
119
+ name: expect.any(String),
120
+ description: expect.toBeOneOf([expect.any(String), null]),
121
+ creator: {
122
+ id: expect.any(Number),
123
+ type: expect.any(String)
124
+ },
125
+ rootPlace: {
126
+ id: expect.any(Number),
127
+ type: expect.any(String)
128
+ },
129
+ created: expect.any(Date),
130
+ updated: expect.any(Date),
131
+ placeVisits: expect.any(Number)
132
+ })
133
+ })
134
+ })
135
+
136
+ it('getUniverseInfo() should return information about universes', () => {
137
+ return getUniverseInfo(2152417643).then((res) => {
138
+ return expect(res).toEqual(
139
+ expect.arrayContaining([
140
+ expect.objectContaining({
141
+ id: expect.any(Number),
142
+ rootPlaceId: expect.any(Number),
143
+ name: expect.any(String),
144
+ description: expect.any(String),
145
+ creator: expect.objectContaining({
146
+ id: expect.any(Number),
147
+ name: expect.any(String),
148
+ type: expect.any(String),
149
+ isRNVAccount: expect.any(Boolean)
150
+ }),
151
+ allowedGearGenres: expect.any(Array),
152
+ allowedGearCategories: expect.any(Array),
153
+ isGenreEnforced: expect.any(Boolean),
154
+ copyingAllowed: expect.any(Boolean),
155
+ playing: expect.any(Number),
156
+ visits: expect.any(Number),
157
+ maxPlayers: expect.any(Number),
158
+ created: expect.any(Date),
159
+ updated: expect.any(Date),
160
+ studioAccessToApisAllowed: expect.any(Boolean),
161
+ createVipServersAllowed: expect.any(Boolean),
162
+ universeAvatarType: expect.any(String),
163
+ genre: expect.any(String),
164
+ isAllGenre: expect.any(Boolean),
165
+ isFavoritedByUser: expect.any(Boolean),
166
+ favoritedCount: expect.any(Number)
167
+ })
168
+ ])
169
+ )
170
+ })
171
+ })
172
+
173
+ it('getPlaceInfo() should return an array of information about places', () => {
174
+ return getPlaceInfo(10905034443).then((res) => {
175
+ return expect(res).toEqual(
176
+ expect.arrayContaining([
177
+ expect.objectContaining({
178
+ placeId: expect.any(Number),
179
+ name: expect.any(String),
180
+ sourceName: expect.any(String),
181
+ sourceDescription: expect.any(String),
182
+ url: expect.any(String),
183
+ builder: expect.any(String),
184
+ builderId: expect.any(Number),
185
+ hasVerifiedBadge: expect.any(Boolean),
186
+ isPlayable: expect.any(Boolean),
187
+ reasonProhibited: expect.any(String),
188
+ universeId: expect.any(Number),
189
+ universeRootPlaceId: expect.any(Number),
190
+ price: expect.any(Number),
191
+ imageToken: expect.any(String)
192
+ })
193
+ ])
194
+ )
195
+ })
196
+ })
197
+
198
+ it('sendUserNotification() should successfully send a user notification', async () => {
199
+ const { id: userId } = await getAuthenticatedUser()
200
+
201
+ return await expect(
202
+ sendUserNotification({
203
+ universeId: 2152417643,
204
+ userId,
205
+ assetId: "",
206
+ parameters: {
207
+ test: "test"
208
+ }
209
+ })
210
+ ).resolves.not.toThrow()
211
+ })
212
+
213
+ // Dependency on getDeveloperProducts() which is broken as of 4.14.0
214
+ // eslint-disable-next-line jest/no-commented-out-tests
215
+ // it('updateDeveloperProduct() should update a developer product with new information', () => {
216
+ // return getDeveloperProducts(166178819).then((productsData) => {
217
+ // const developerProduct = productsData.DeveloperProducts.filter((product) => product.ProductId === newProductId)[0]
218
+ // return updateDeveloperProduct(79354837, developerProduct.DeveloperProductId, `Test${Date.now().toString().slice(-6)}`, 104, 'Currently unit testing.').then((res) => {
219
+ // return expect(res).toMatchObject({
220
+ // universeId: 79354837,
221
+ // name: expect.any(String), // account for Roblox filters
222
+ // priceInRobux: 104,
223
+ // description: expect.any(String), // account for Roblox filters
224
+ // developerProductId: developerProduct.DeveloperProductId
225
+ // })
226
+ // })
227
+ // })
228
+ // })
229
+ })
@@ -0,0 +1,405 @@
1
+ const { banFromGroup, changeRank, demote, getAuditLog, getGroup, getGroupBans, getGroups, getGroupSocialLinks, getJoinRequests, getPlayers, getRankInGroup, getRankNameInGroup, getRole, getRolePermissions, getRoles, getShout, getWall, promote, searchGroups, setRank, shout, setCookie, unbanFromGroup } = require('../lib')
2
+
3
+ beforeAll(() => {
4
+ return new Promise(resolve => {
5
+ setCookie(process.env.COOKIE).then(() => {
6
+ resolve()
7
+ })
8
+ })
9
+ })
10
+
11
+ describe('Groups Methods', () => {
12
+ it('changeRank() changes rank of a user', () => {
13
+ return changeRank(4591072, 857710783, 1).then((res) => {
14
+ setTimeout(async () => {
15
+ await changeRank(4591072, 857710783, -1)
16
+ }, 1000)
17
+ return expect(res).toMatchObject({
18
+ newRole: expect.any(Object),
19
+ oldRole: expect.any(Object)
20
+ })
21
+ })
22
+ })
23
+
24
+ it('promote() promotes a user', () => {
25
+ return promote(4591072, 857710783).then((res) => {
26
+ return expect(res).toMatchObject({
27
+ newRole: expect.objectContaining({
28
+ name: expect.any(String),
29
+ rank: expect.any(Number),
30
+ id: expect.any(Number)
31
+ }),
32
+ oldRole: expect.objectContaining({
33
+ name: expect.any(String),
34
+ rank: expect.any(Number),
35
+ id: expect.any(Number)
36
+ })
37
+ })
38
+ })
39
+ })
40
+
41
+ it('demote() demotes a user', () => {
42
+ return demote(4591072, 857710783).then((res) => {
43
+ return expect(res).toMatchObject({
44
+ newRole: expect.objectContaining({
45
+ name: expect.any(String),
46
+ rank: expect.any(Number),
47
+ id: expect.any(Number)
48
+ }),
49
+ oldRole: expect.objectContaining({
50
+ name: expect.any(String),
51
+ rank: expect.any(Number),
52
+ id: expect.any(Number)
53
+ })
54
+ })
55
+ })
56
+ })
57
+
58
+ it('getAuditLog() returns a group\'s audit logs', () => {
59
+ return getAuditLog({ group: 4591072, limit: 10 }).then(res => {
60
+ return expect(res).toMatchObject({
61
+ previousPageCursor: expect.toBeOneOf([expect.any(String), null]),
62
+ nextPageCursor: expect.toBeOneOf([expect.any(String), null]),
63
+ data: expect.arrayContaining([
64
+ expect.objectContaining({
65
+ actor: expect.objectContaining({
66
+ user: expect.objectContaining({
67
+ hasVerifiedBadge: expect.any(Boolean),
68
+ userId: expect.any(Number),
69
+ username: expect.any(String),
70
+ displayName: expect.any(String)
71
+ }),
72
+ role: expect.objectContaining({
73
+ id: expect.any(Number),
74
+ name: expect.any(String),
75
+ rank: expect.any(Number)
76
+ })
77
+ }),
78
+ actionType: expect.any(String),
79
+ description: expect.any(Object),
80
+ created: expect.any(Date)
81
+ })
82
+ ])
83
+ })
84
+ })
85
+ })
86
+
87
+ it('getGroup() returns information on a group', () => {
88
+ return getGroup(4591072).then((res) => {
89
+ return expect(res).toMatchObject({
90
+ id: expect.any(Number),
91
+ name: expect.any(String),
92
+ description: expect.any(String),
93
+ owner: {
94
+ userId: expect.any(Number),
95
+ username: expect.any(String),
96
+ hasVerifiedBadge: expect.any(Boolean),
97
+ displayName: expect.any(String)
98
+ },
99
+ shout: expect.objectContaining({
100
+ body: expect.any(String),
101
+ poster: expect.objectContaining({
102
+ hasVerifiedBadge: expect.any(Boolean),
103
+ userId: expect.any(Number),
104
+ username: expect.any(String),
105
+ displayName: expect.any(String)
106
+ }),
107
+ created: expect.any(Date),
108
+ updated: expect.any(Date)
109
+ }),
110
+ memberCount: expect.any(Number),
111
+ isBuildersClubOnly: expect.any(Boolean),
112
+ publicEntryAllowed: expect.any(Boolean),
113
+ hasVerifiedBadge: expect.any(Boolean)
114
+ })
115
+ })
116
+ })
117
+
118
+ it('getGroups() should return groups the specified user is in', async () => {
119
+ return getGroups(55549140).then((res) => {
120
+ return expect(res).toEqual(
121
+ expect.arrayContaining([
122
+ expect.objectContaining({
123
+ Id: expect.any(Number),
124
+ Name: expect.any(String),
125
+ EmblemUrl: expect.any(String),
126
+ MemberCount: expect.any(Number),
127
+ Rank: expect.any(Number),
128
+ Role: expect.any(String),
129
+ RoleId: expect.any(Number),
130
+ IsPrimary: expect.any(Boolean)
131
+ })
132
+ ])
133
+ )
134
+ })
135
+ })
136
+
137
+ it('getGroupSocialLinks() should return social link information of a game, given universeId', () => {
138
+ return getGroupSocialLinks(9997719).then((res) => {
139
+ return expect(res).toEqual(
140
+ expect.arrayContaining([
141
+ expect.objectContaining({
142
+ id: expect.any(Number),
143
+ title: expect.any(String),
144
+ type: expect.any(String),
145
+ url: expect.any(String)
146
+ })
147
+ ])
148
+ )
149
+ })
150
+ })
151
+
152
+ // TODO: getJoinRequest, would require being able to request to join a group
153
+
154
+ it('getJoinRequests() returns a list of players that want to join a group', () => {
155
+ return getJoinRequests(4591072).then((res) => {
156
+ return expect(res).toMatchObject({
157
+ previousPageCursor: expect.toBeOneOf([expect.any(String), null]),
158
+ nextPageCursor: expect.toBeOneOf([expect.any(String), null]),
159
+ data: expect.any(Array)
160
+ })
161
+ })
162
+ })
163
+
164
+ it('getPlayers() returns a list of players in a group', () => {
165
+ return getPlayers(4591072, [30820744]).then((res) => {
166
+ return expect(res).toEqual(
167
+ expect.arrayContaining([
168
+ expect.objectContaining({
169
+ userId: expect.any(Number),
170
+ username: expect.any(String)
171
+ })
172
+ ])
173
+ )
174
+ })
175
+ })
176
+
177
+ it('getRankInGroup() returns a number reflecting a user\'s rank in a group (0-255)', () => {
178
+ return getRankInGroup(4591072, 55549140).then((res) => {
179
+ return expect(res).toEqual(expect.any(Number))
180
+ })
181
+ })
182
+
183
+ it('getRankNameInGroup() returns a number reflecting a user\'s rank name in a group', () => {
184
+ return getRankNameInGroup(4591072, 55549140).then((res) => {
185
+ return expect(res).toEqual(expect.any(String))
186
+ })
187
+ })
188
+
189
+ it('getRole() returns a role that matches the provided rank', () => {
190
+ return getRole(4591072, 255).then((res) => {
191
+ return expect(res).toMatchObject({
192
+ name: expect.any(String),
193
+ rank: expect.any(Number),
194
+ memberCount: expect.any(Number),
195
+ ID: expect.any(Number)
196
+ })
197
+ })
198
+ })
199
+
200
+ it('getRolePermissions() returns permissions given to a role by a group', () => {
201
+ return getRolePermissions(4591072, 30820744).then((res) => {
202
+ return expect(res).toMatchObject({
203
+ groupId: expect.any(Number),
204
+ role: expect.any(Object),
205
+ permissions: expect.any(Object)
206
+ })
207
+ })
208
+ })
209
+
210
+ it('getRoles() returns the roles in a group', () => {
211
+ return getRoles(4591072).then((res) => {
212
+ return expect(res).toEqual(
213
+ expect.arrayContaining([
214
+ expect.objectContaining({
215
+ name: expect.any(String),
216
+ rank: expect.any(Number),
217
+ memberCount: expect.any(Number),
218
+ ID: expect.any(Number)
219
+ })
220
+ ])
221
+ )
222
+ })
223
+ })
224
+
225
+ it('getShout() returns the current shout on a group', () => {
226
+ return getShout(4591072).then((res) => {
227
+ return expect(res).toMatchObject({
228
+ body: expect.any(String),
229
+ poster: {
230
+ userId: expect.any(Number),
231
+ username: expect.any(String)
232
+ },
233
+ created: expect.any(String),
234
+ updated: expect.any(String)
235
+ })
236
+ })
237
+ })
238
+
239
+ it('getWall() returns the latest messages on the group wall', () => {
240
+ return getWall(4591072).then((res) => {
241
+ return expect(res).toMatchObject({
242
+ previousPageCursor: expect.toBeOneOf([expect.any(String), null]),
243
+ nextPageCursor: expect.toBeOneOf([expect.any(String), null]),
244
+ data: expect.arrayContaining([
245
+ expect.objectContaining({
246
+ id: expect.any(Number),
247
+ poster: expect.toBeOneOf([expect.any(Object), null]),
248
+ body: expect.any(String),
249
+ created: expect.any(Date),
250
+ updated: expect.any(Date)
251
+ })
252
+ ])
253
+ })
254
+ })
255
+ })
256
+
257
+ // PASS: groupPayout, costs Robux to test
258
+
259
+ // PASS: handleJoinRequest, would require being able to request to join a group
260
+
261
+ // PASS: handleJoinRequests, would require being able to request to join a group
262
+
263
+ // PASS: leaveGroup, would require being able to request to join a group
264
+
265
+ it('searchGroups() returns groups that match the query', () => {
266
+ return searchGroups('noblox.js').then((res) => {
267
+ return expect(res).toEqual(
268
+ expect.arrayContaining([expect.objectContaining({
269
+ id: expect.any(Number),
270
+ name: expect.any(String),
271
+ description: expect.any(String),
272
+ memberCount: expect.any(Number),
273
+ publicEntryAllowed: expect.any(Boolean),
274
+ created: expect.any(Date),
275
+ updated: expect.any(Date)
276
+ })]))
277
+ })
278
+ })
279
+
280
+ // PASS: setGroupDescription -- skip this, do not own group
281
+
282
+ // PASS: setGroupName -- skip this, costs Robux
283
+
284
+ it('setRank() should set a player\'s rank to the specified rank', () => {
285
+ return changeRank(4591072, 857710783, 2).then(() => {
286
+ return setRank(4591072, 857710783, 1).then((res) => {
287
+ return expect(res).toMatchObject({
288
+ name: expect.any(String),
289
+ rank: expect.any(Number),
290
+ memberCount: expect.any(Number),
291
+ ID: expect.any(Number)
292
+ })
293
+ })
294
+ })
295
+ })
296
+
297
+ it('shout() should post a message to the group\'s shout', () => {
298
+ return shout(4591072, 'This is a noblox.js test!').then((res) => {
299
+ setTimeout(async () => {
300
+ await shout(4591072, '')
301
+ }, 1000)
302
+ return expect(res).toMatchObject({
303
+ body: expect.any(String),
304
+ poster: {
305
+ userId: expect.any(Number),
306
+ username: expect.any(String)
307
+ },
308
+ created: expect.any(String),
309
+ updated: expect.any(String)
310
+ })
311
+ })
312
+ })
313
+
314
+ it('banFromGroup() should ban a user from the specified group', () => {
315
+ return banFromGroup(4591072, 1).then((res) => {
316
+ return expect(res).toMatchObject({
317
+ user: {
318
+ hasVerifiedBadge: expect.any(Boolean),
319
+ userId: expect.any(Number),
320
+ username: expect.any(String),
321
+ displayName: expect.any(String)
322
+ },
323
+ actingUser: {
324
+ user: {
325
+ hasVerifiedBadge: expect.any(Boolean),
326
+ userId: expect.any(Number),
327
+ username: expect.any(String),
328
+ displayName: expect.any(String)
329
+ },
330
+ role: {
331
+ id: expect.any(Number),
332
+ name: expect.any(String),
333
+ rank: expect.any(Number)
334
+ }
335
+ },
336
+ created: expect.any(Date)
337
+ })
338
+ })
339
+ })
340
+
341
+ it('getGroupBans() should retrieve a page of group bans', () => {
342
+ return getGroupBans(4591072, 10, 'Asc').then((res) => {
343
+ return expect(res).toEqual(
344
+ expect.arrayContaining([
345
+ expect.objectContaining({
346
+ user: {
347
+ hasVerifiedBadge: expect.any(Boolean),
348
+ userId: expect.any(Number),
349
+ username: expect.any(String),
350
+ displayName: expect.any(String)
351
+ },
352
+ actingUser: {
353
+ user: {
354
+ hasVerifiedBadge: expect.any(Boolean),
355
+ userId: expect.any(Number),
356
+ username: expect.any(String),
357
+ displayName: expect.any(String)
358
+ },
359
+ role: {
360
+ id: expect.any(Number),
361
+ name: expect.any(String),
362
+ rank: expect.any(Number)
363
+ }
364
+ },
365
+ created: expect.any(Date)
366
+ })
367
+ ])
368
+ )
369
+ })
370
+ })
371
+
372
+ it('unbanFromGroup() should unban a user from a group', async () => {
373
+ await expect(unbanFromGroup(4591072, 1)).resolves.not.toThrow()
374
+ })
375
+ })
376
+
377
+ it('setRank() should set a player\'s rank to the specified rank', () => {
378
+ return changeRank(4591072, 857710783, 2).then(() => {
379
+ return setRank(4591072, 857710783, 1).then((res) => {
380
+ return expect(res).toMatchObject({
381
+ name: expect.any(String),
382
+ rank: expect.any(Number),
383
+ memberCount: expect.any(Number),
384
+ ID: expect.any(Number)
385
+ })
386
+ })
387
+ })
388
+ })
389
+
390
+
391
+ // PASS: setRoleInfo -- skip this, do not own group
392
+
393
+ // it('setRoleInfo() should update a role\'s information', () => {
394
+ // return getRole(4591072, 1).then((originalRoleInfo) => {
395
+ // return setRoleInfo(4591072, 1, { name: 'Programmer', description: 'Programs on roblox n stuff', rank: 2 }).then((res) => {
396
+ // return setRoleInfo(4591072, "Programmer", originalRoleInfo).then(() => {
397
+ // return expect(res).toMatchObject({
398
+ // name: expect.any(String),
399
+ // rank: expect.any(Number),
400
+ // description: expect.any(String)
401
+ // })
402
+ // })
403
+ // })
404
+ // })
405
+ // })