noblox.ts 4.10.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of noblox.ts might be problematic. Click here for more details.

Files changed (259) hide show
  1. package/.eslintrc.js +21 -0
  2. package/.github/FUNDING.yml +3 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
  5. package/.github/workflows/doc-publish.yml +33 -0
  6. package/.github/workflows/npmpublish.yml +70 -0
  7. package/.travis.yml +13 -0
  8. package/CODE_OF_CONDUCT.md +76 -0
  9. package/LICENSE +21 -0
  10. package/README.md +168 -0
  11. package/examples/cleanPlayers.js +130 -0
  12. package/examples/cleanWall.js +110 -0
  13. package/examples/revertRanks.js +100 -0
  14. package/examples/savePlayers.js +119 -0
  15. package/examples/saveWall.js +96 -0
  16. package/img/moderatedThumbnails/moderatedThumbnail_100x100.png +0 -0
  17. package/img/moderatedThumbnails/moderatedThumbnail_110x110.png +0 -0
  18. package/img/moderatedThumbnails/moderatedThumbnail_140x140.png +0 -0
  19. package/img/moderatedThumbnails/moderatedThumbnail_150x150.png +0 -0
  20. package/img/moderatedThumbnails/moderatedThumbnail_150x200.png +0 -0
  21. package/img/moderatedThumbnails/moderatedThumbnail_180x180.png +0 -0
  22. package/img/moderatedThumbnails/moderatedThumbnail_250x250.png +0 -0
  23. package/img/moderatedThumbnails/moderatedThumbnail_30x30.png +0 -0
  24. package/img/moderatedThumbnails/moderatedThumbnail_352x352.png +0 -0
  25. package/img/moderatedThumbnails/moderatedThumbnail_420x420.png +0 -0
  26. package/img/moderatedThumbnails/moderatedThumbnail_48x48.png +0 -0
  27. package/img/moderatedThumbnails/moderatedThumbnail_50x50.png +0 -0
  28. package/img/moderatedThumbnails/moderatedThumbnail_60x60.png +0 -0
  29. package/img/moderatedThumbnails/moderatedThumbnail_720x720.png +0 -0
  30. package/img/moderatedThumbnails/moderatedThumbnail_75x75.png +0 -0
  31. package/img/noblox-js-small.png +0 -0
  32. package/img/noblox-js.png +0 -0
  33. package/img/thumbnailSizes.png +0 -0
  34. package/jsDocsConfig.json +55 -0
  35. package/lib/accountinformation/getUserSocialLinks.js +42 -0
  36. package/lib/accountsettings/block.js +58 -0
  37. package/lib/accountsettings/unblock.js +58 -0
  38. package/lib/asset/deleteFromInventory.js +69 -0
  39. package/lib/asset/getGamePassProductInfo.js +51 -0
  40. package/lib/asset/getProductInfo.js +56 -0
  41. package/lib/asset/uploadAnimation.js +103 -0
  42. package/lib/asset/uploadItem.js +83 -0
  43. package/lib/asset/uploadModel.js +90 -0
  44. package/lib/avatar/avatarRules.js +38 -0
  45. package/lib/avatar/currentlyWearing.js +32 -0
  46. package/lib/avatar/getAvatar.js +35 -0
  47. package/lib/avatar/getCurrentAvatar.js +37 -0
  48. package/lib/avatar/getRecentItems.js +37 -0
  49. package/lib/avatar/outfitDetails.js +32 -0
  50. package/lib/avatar/outfits.js +37 -0
  51. package/lib/avatar/redrawAvatar.js +48 -0
  52. package/lib/avatar/removeAssetId.js +55 -0
  53. package/lib/avatar/setAvatarBodyColors.js +60 -0
  54. package/lib/avatar/setAvatarScales.js +60 -0
  55. package/lib/avatar/setPlayerAvatarType.js +50 -0
  56. package/lib/avatar/setWearingAssets.js +50 -0
  57. package/lib/avatar/wearAssetId.js +55 -0
  58. package/lib/badges/getAwardedTimestamps.js +52 -0
  59. package/lib/badges/getBadgeInfo.js +43 -0
  60. package/lib/badges/getGameBadges.js +62 -0
  61. package/lib/badges/getPlayerBadges.js +28 -0
  62. package/lib/badges/updateBadgeInfo.js +80 -0
  63. package/lib/cache/add.js +14 -0
  64. package/lib/cache/addIf.js +26 -0
  65. package/lib/cache/clear.js +8 -0
  66. package/lib/cache/get.js +28 -0
  67. package/lib/cache/index.js +17 -0
  68. package/lib/cache/new.js +12 -0
  69. package/lib/cache/wrap.js +25 -0
  70. package/lib/chat/addUsersToConversation.js +61 -0
  71. package/lib/chat/chatSettings.js +33 -0
  72. package/lib/chat/getChatMessages.js +40 -0
  73. package/lib/chat/getConversations.js +43 -0
  74. package/lib/chat/getRolloutSettings.js +35 -0
  75. package/lib/chat/getUnreadConversationCount.js +33 -0
  76. package/lib/chat/getUnreadMessages.js +38 -0
  77. package/lib/chat/getUserConversations.js +37 -0
  78. package/lib/chat/markChatAsRead.js +52 -0
  79. package/lib/chat/markChatAsSeen.js +50 -0
  80. package/lib/chat/multiGetLatestMessages.js +37 -0
  81. package/lib/chat/onNewConversation.js +50 -0
  82. package/lib/chat/onNewMessage.js +53 -0
  83. package/lib/chat/onNewMessageBySelf.js +50 -0
  84. package/lib/chat/onUserOnline.js +50 -0
  85. package/lib/chat/onUserTyping.js +54 -0
  86. package/lib/chat/removeFromGroupConversation.js +62 -0
  87. package/lib/chat/renameGroupConversation.js +57 -0
  88. package/lib/chat/sendChatMessage.js +57 -0
  89. package/lib/chat/setChatUserTyping.js +61 -0
  90. package/lib/chat/start121Conversation.js +50 -0
  91. package/lib/chat/startCloudEditConversation.js +50 -0
  92. package/lib/chat/startGroupConversation.js +62 -0
  93. package/lib/client/onNotification.js +70 -0
  94. package/lib/client/setAPIKey.js +18 -0
  95. package/lib/client/setCookie.js +38 -0
  96. package/lib/datastores/deleteDatastoreEntry.js +66 -0
  97. package/lib/datastores/getDatastoreEntry.js +98 -0
  98. package/lib/datastores/getDatastoreEntryVersions.js +83 -0
  99. package/lib/datastores/getDatastoreKeys.js +73 -0
  100. package/lib/datastores/getDatastores.js +72 -0
  101. package/lib/datastores/incrementDatastoreEntry.js +93 -0
  102. package/lib/datastores/setDatastoreEntry.js +90 -0
  103. package/lib/develop/canManage.js +44 -0
  104. package/lib/develop/configureItem.js +142 -0
  105. package/lib/develop/updateUniverse.js +53 -0
  106. package/lib/develop/updateUniverseAccess.js +55 -0
  107. package/lib/economy/buy.js +99 -0
  108. package/lib/economy/getGroupFunds.js +43 -0
  109. package/lib/economy/getGroupRevenueSummary.js +48 -0
  110. package/lib/economy/getGroupTransactions.js +32 -0
  111. package/lib/economy/getResaleData.js +54 -0
  112. package/lib/economy/getResellers.js +35 -0
  113. package/lib/economy/getUserTransactions.js +34 -0
  114. package/lib/economy/onGroupTransaction.js +74 -0
  115. package/lib/friends/acceptFriendRequest.js +59 -0
  116. package/lib/friends/declineAllFriendRequests.js +57 -0
  117. package/lib/friends/declineFriendRequest.js +59 -0
  118. package/lib/friends/getFollowers.js +61 -0
  119. package/lib/friends/getFollowings.js +61 -0
  120. package/lib/friends/getFriendRequests.js +56 -0
  121. package/lib/friends/getFriends.js +53 -0
  122. package/lib/friends/onFriendRequest.js +58 -0
  123. package/lib/friends/removeFriend.js +58 -0
  124. package/lib/friends/sendFriendRequest.js +59 -0
  125. package/lib/friends/unfollow.js +58 -0
  126. package/lib/games/addDeveloperProduct.js +65 -0
  127. package/lib/games/checkDeveloperProductName.js +39 -0
  128. package/lib/games/configureGamePass.js +146 -0
  129. package/lib/games/getDeveloperProducts.js +51 -0
  130. package/lib/games/getGameInstances.js +31 -0
  131. package/lib/games/getGamePasses.js +39 -0
  132. package/lib/games/getGameRevenue.js +49 -0
  133. package/lib/games/getGameSocialLinks.js +45 -0
  134. package/lib/games/getGroupGames.js +30 -0
  135. package/lib/games/getPlaceInfo.js +48 -0
  136. package/lib/games/getUniverseInfo.js +51 -0
  137. package/lib/games/updateDeveloperProduct.js +69 -0
  138. package/lib/groups/changeRank.js +59 -0
  139. package/lib/groups/deleteWallPost.js +64 -0
  140. package/lib/groups/deleteWallPostsByUser.js +59 -0
  141. package/lib/groups/demote.js +25 -0
  142. package/lib/groups/exile.js +59 -0
  143. package/lib/groups/getAuditLog.js +67 -0
  144. package/lib/groups/getGroup.js +57 -0
  145. package/lib/groups/getGroupSocialLinks.js +44 -0
  146. package/lib/groups/getGroups.js +88 -0
  147. package/lib/groups/getJoinRequest.js +52 -0
  148. package/lib/groups/getJoinRequests.js +58 -0
  149. package/lib/groups/getPlayers.js +108 -0
  150. package/lib/groups/getRankInGroup.js +52 -0
  151. package/lib/groups/getRankNameInGroup.js +52 -0
  152. package/lib/groups/getRole.js +64 -0
  153. package/lib/groups/getRolePermissions.js +51 -0
  154. package/lib/groups/getRoles.js +56 -0
  155. package/lib/groups/getShout.js +49 -0
  156. package/lib/groups/getWall.js +59 -0
  157. package/lib/groups/groupPayout.js +103 -0
  158. package/lib/groups/handleJoinRequest.js +60 -0
  159. package/lib/groups/leaveGroup.js +60 -0
  160. package/lib/groups/onAuditLog.js +62 -0
  161. package/lib/groups/onJoinRequest.js +63 -0
  162. package/lib/groups/onJoinRequestHandle.js +105 -0
  163. package/lib/groups/onShout.js +57 -0
  164. package/lib/groups/onWallPost.js +58 -0
  165. package/lib/groups/promote.js +25 -0
  166. package/lib/groups/searchGroups.js +32 -0
  167. package/lib/groups/setGroupDescription.js +65 -0
  168. package/lib/groups/setGroupName.js +66 -0
  169. package/lib/groups/setRank.js +79 -0
  170. package/lib/groups/shout.js +65 -0
  171. package/lib/index.js +30 -0
  172. package/lib/internal/levelOneCopy.js +16 -0
  173. package/lib/internal/queue.js +61 -0
  174. package/lib/internal/timeout.js +30 -0
  175. package/lib/internal/wrap.js +78 -0
  176. package/lib/inventory/getCollectibles.js +31 -0
  177. package/lib/inventory/getInventory.js +32 -0
  178. package/lib/inventory/getInventoryById.js +31 -0
  179. package/lib/inventory/getOwnership.js +54 -0
  180. package/lib/inventory/getUAIDs.js +47 -0
  181. package/lib/itemconfiguration/getGroupAssets.js +32 -0
  182. package/lib/options.js +26 -0
  183. package/lib/party/onPartyDeleted.js +53 -0
  184. package/lib/party/onPartyInvite.js +53 -0
  185. package/lib/party/onPartyJoinedGame.js +53 -0
  186. package/lib/party/onPartyLeftGame.js +53 -0
  187. package/lib/party/onPartySelfJoined.js +53 -0
  188. package/lib/party/onPartySelfLeft.js +53 -0
  189. package/lib/party/onPartyUserJoined.js +53 -0
  190. package/lib/party/onPartyUserLeft.js +53 -0
  191. package/lib/premiumfeatures/getPremium.js +51 -0
  192. package/lib/presence/getPresences.js +63 -0
  193. package/lib/privatemessages/getMessages.js +60 -0
  194. package/lib/privatemessages/message.js +80 -0
  195. package/lib/privatemessages/onMessage.js +88 -0
  196. package/lib/thumbnails/getLogo.js +60 -0
  197. package/lib/thumbnails/getPlayerThumbnail.js +121 -0
  198. package/lib/thumbnails/getThumbnails.js +93 -0
  199. package/lib/trades/acceptTrade.js +58 -0
  200. package/lib/trades/canTradeWith.js +48 -0
  201. package/lib/trades/counterTrade.js +84 -0
  202. package/lib/trades/declineTrade.js +58 -0
  203. package/lib/trades/getTradeInfo.js +52 -0
  204. package/lib/trades/getTrades.js +37 -0
  205. package/lib/trades/sendTrade.js +82 -0
  206. package/lib/users/getBlurb.js +36 -0
  207. package/lib/users/getIdFromUsername.js +53 -0
  208. package/lib/users/getPlayerInfo.js +100 -0
  209. package/lib/users/getUsernameFromId.js +44 -0
  210. package/lib/users/onBlurbChange.js +46 -0
  211. package/lib/util/clearSession.js +32 -0
  212. package/lib/util/generalRequest.js +61 -0
  213. package/lib/util/getAction.js +45 -0
  214. package/lib/util/getCurrentUser.js +44 -0
  215. package/lib/util/getGeneralToken.js +52 -0
  216. package/lib/util/getHash.js +29 -0
  217. package/lib/util/getInputs.js +37 -0
  218. package/lib/util/getPageResults.js +89 -0
  219. package/lib/util/getSenderUserId.js +30 -0
  220. package/lib/util/getSession.js +38 -0
  221. package/lib/util/getVerification.js +60 -0
  222. package/lib/util/getVerificationInputs.js +31 -0
  223. package/lib/util/http.js +110 -0
  224. package/lib/util/jar.js +24 -0
  225. package/lib/util/refreshCookie.js +52 -0
  226. package/lib/util/relog.js +81 -0
  227. package/lib/util/setOptions.js +54 -0
  228. package/lib/util/shortPoll.js +102 -0
  229. package/lib/util/threaded.js +80 -0
  230. package/package.json +94 -0
  231. package/postinstall.js +1 -0
  232. package/settings.json +107 -0
  233. package/test/accountinformation.test.js +27 -0
  234. package/test/accountsettings.test.js +27 -0
  235. package/test/asset.test.js +81 -0
  236. package/test/assets/Great-White-Shark-Fin.rbxm +0 -0
  237. package/test/assets/KeyframeSequence.rbxm +0 -0
  238. package/test/avatar.test.js +164 -0
  239. package/test/badges.test.js +96 -0
  240. package/test/chat.test.js +104 -0
  241. package/test/datastore.test.js +105 -0
  242. package/test/develop.test.js +53 -0
  243. package/test/economy.test.js +137 -0
  244. package/test/friends.test.js +128 -0
  245. package/test/games.test.js +212 -0
  246. package/test/groups.test.js +311 -0
  247. package/test/inventory.test.js +98 -0
  248. package/test/itemconfiguration.test.js +24 -0
  249. package/test/premiumfeatures.test.js +17 -0
  250. package/test/presence.test.js +25 -0
  251. package/test/privatemessages.test.js +33 -0
  252. package/test/thumbnails.test.js +53 -0
  253. package/test/users.test.js +68 -0
  254. package/tutorials/Authentication.md +75 -0
  255. package/tutorials/Event Emitters.md +26 -0
  256. package/tutorials/Promises.md +86 -0
  257. package/tutorials/VPS Authentication.md +72 -0
  258. package/typings/index.d.ts +2525 -0
  259. package/typings/jsDocs.ts +1927 -0
@@ -0,0 +1,81 @@
1
+ const { buy, deleteFromInventory, getGamePassProductInfo, getProductInfo, uploadAnimation, uploadItem, uploadModel, setCookie, getOwnership, getCurrentUser } = require('../lib')
2
+ const fs = require('fs')
3
+
4
+ beforeAll(() => {
5
+ return new Promise(resolve => {
6
+ setCookie(process.env.COOKIE).then(() => {
7
+ resolve()
8
+ })
9
+ })
10
+ })
11
+
12
+ describe('Asset Methods', () => {
13
+ it('deleteFromInventory() successfully deletes an item from user\'s inventory', async () => {
14
+ await getOwnership(await getCurrentUser('UserId'), 1778181).then((res) => {
15
+ if (!res) return buy(1778181)
16
+ })
17
+ return await expect(deleteFromInventory(1778181)).resolves.not.toThrow()
18
+ })
19
+
20
+ it('deleteFromInventory() errors when it tries to delete an item from user\'s inventory that isn\'t there', async () => {
21
+ return await expect(deleteFromInventory(1778181)).rejects.toThrow()
22
+ })
23
+
24
+ it('getGamePassProductInfo() successfully returns a gamepass\'s information', () => {
25
+ return getGamePassProductInfo(2919875).then((res) => {
26
+ return expect(res).toMatchObject({
27
+ Name: expect.any(String),
28
+ Description: expect.any(String),
29
+ Creator: expect.any(Object),
30
+ PriceInRobux: expect.toBeOneOf([expect.any(Number), null])
31
+ })
32
+ })
33
+ })
34
+
35
+ it('getGamePassProductInfo() errors when returning a product\'s information that does not exist', async () => {
36
+ return await expect(getGamePassProductInfo(0)).rejects.toThrow()
37
+ })
38
+
39
+ it('getProductInfo() successfully returns a product\'s information', () => {
40
+ return getProductInfo(1989194006).then((res) => {
41
+ return expect(res).toMatchObject({
42
+ AssetId: expect.any(Number),
43
+ ProductId: expect.any(Number),
44
+ Name: expect.any(String),
45
+ Description: expect.any(String),
46
+ Creator: expect.any(Object),
47
+ PriceInRobux: expect.toBeOneOf([expect.any(Number), null])
48
+ })
49
+ })
50
+ })
51
+
52
+ it('getProductInfo() errors when returning a product\'s information that does not exist', async () => {
53
+ return await expect(getProductInfo(3)).rejects.toThrow()
54
+ })
55
+
56
+ it('uploadAnimation() uploads an animation', () => {
57
+ return uploadAnimation(fs.createReadStream('./test/assets/KeyframeSequence.rbxm'), { name: 'noblox', description: 'A noblox test!', copyLocked: true, allowComments: false }).then((res) => {
58
+ return expect(res).toEqual(expect.any(Number))
59
+ })
60
+ })
61
+
62
+ it('uploadAnimation() errors when no options are provided', async () => {
63
+ await expect(uploadAnimation(fs.createReadStream('./test/assets/KeyframeSequence.rbxm'))).rejects.toThrow()
64
+ })
65
+
66
+ it('uploadItem() uploads an image', async () => {
67
+ await expect(uploadItem('noblox', 13, fs.createReadStream('./img/noblox-js.png'))).resolves.not.toThrow()
68
+ })
69
+
70
+ it('uploadModel() uploads a model', async () => {
71
+ await expect(uploadModel(fs.createReadStream('./test/assets/Great-White-Shark-Fin.rbxm'), {
72
+ name: 'Shark Fin',
73
+ description: 'Uploaded via noblox',
74
+ copyLocked: true
75
+ })).resolves.not.toThrow()
76
+ })
77
+
78
+ it('uploadModel() errors when no options are provided', async () => {
79
+ await expect(uploadModel(fs.createReadStream('./test/assets/Great-White-Shark-Fin.rbxm'))).rejects.toThrow()
80
+ })
81
+ })
@@ -0,0 +1,164 @@
1
+ const { avatarRules, currentlyWearing, getAvatar, getCurrentAvatar, getRecentItems, outfitDetails, outfits, redrawAvatar, removeAssetId, setAvatarBodyColors, setAvatarScales, setPlayerAvatarType, setWearingAssets, wearAssetId, setCookie } = require('../lib')
2
+
3
+ beforeAll(() => {
4
+ return new Promise(resolve => {
5
+ setCookie(process.env.COOKIE).then(() => {
6
+ resolve()
7
+ })
8
+ })
9
+ })
10
+
11
+ describe('Avatar Methods', () => {
12
+ it('avatarRules() returns avatar rules from Roblox', () => {
13
+ return avatarRules().then((rules) => {
14
+ expect(rules).toMatchObject({
15
+ playerAvatarTypes: expect.any(Array),
16
+ scales: expect.any(Object),
17
+ wearableAssetTypes: expect.any(Array),
18
+ bodyColorsPalette: expect.any(Array),
19
+ basicBodyColorsPalette: expect.any(Array),
20
+ minimumDeltaEBodyColorDifference: expect.any(Number),
21
+ proportionsAndBodyTypeEnabledForUser: expect.any(Boolean),
22
+ defaultClothingAssetLists: expect.any(Object),
23
+ bundlesEnabledForUser: expect.any(Boolean),
24
+ emotesEnabledForUser: expect.any(Boolean)
25
+ })
26
+ })
27
+ })
28
+
29
+ it('currentlyWearing() returns an array containing which assets are being worn by a user', () => {
30
+ return currentlyWearing(1).then((res) => {
31
+ expect(res).toMatchObject({
32
+ assetIds: expect.any(Array)
33
+ })
34
+ })
35
+ })
36
+
37
+ it('getAvatar() returns avatar information on a user', () => {
38
+ return getAvatar(1).then((res) => {
39
+ expect(res).toMatchObject({
40
+ scales: expect.any(Object),
41
+ playerAvatarType: expect.any(String),
42
+ bodyColors: expect.any(Object),
43
+ assets: expect.any(Array),
44
+ defaultShirtApplied: expect.any(Boolean),
45
+ defaultPantsApplied: expect.any(Boolean),
46
+ emotes: expect.any(Array)
47
+ })
48
+ })
49
+ })
50
+
51
+ it('getCurrentAvatar() returns avatar information for logged in user', () => {
52
+ return getCurrentAvatar().then((res) => {
53
+ expect(res).toMatchObject({
54
+ scales: expect.any(Object),
55
+ playerAvatarType: expect.any(String),
56
+ bodyColors: expect.any(Object),
57
+ assets: expect.any(Array),
58
+ defaultShirtApplied: expect.any(Boolean),
59
+ defaultPantsApplied: expect.any(Boolean),
60
+ emotes: expect.any(Array)
61
+ })
62
+ })
63
+ })
64
+
65
+ it('getRecentItems() returns recently worn items for logged in user', () => {
66
+ return getRecentItems('Accessories').then((res) => {
67
+ expect(res).toMatchObject({
68
+ data: expect.any(Array),
69
+ total: expect.any(Number)
70
+ })
71
+ })
72
+ })
73
+
74
+ it('outfitDetails() returns information on a created outfit (costume)', () => {
75
+ return outfitDetails(19461896).then((res) => {
76
+ expect(res).toMatchObject({
77
+ id: expect.any(Number),
78
+ name: expect.any(String),
79
+ assets: expect.any(Array),
80
+ bodyColors: expect.any(Object),
81
+ scale: expect.any(Object),
82
+ playerAvatarType: expect.any(String),
83
+ isEditable: expect.any(Boolean)
84
+ })
85
+ })
86
+ })
87
+
88
+ it('outfits() returns a user\'s oufits', () => {
89
+ return outfits(1).then((res) => {
90
+ expect(res).toMatchObject({
91
+ filteredCount: expect.any(Number),
92
+ data: expect.any(Array),
93
+ total: expect.any(Number)
94
+ })
95
+ })
96
+ })
97
+
98
+ it('redrawAvatar() redraws logged in user\'s avatar or gets flood checked', () => {
99
+ return redrawAvatar().catch((err) => {
100
+ // eslint-disable-next-line jest/no-conditional-expect
101
+ expect(() => { throw new Error(err) }).toThrow('Redraw avatar floodchecked')
102
+ })
103
+ })
104
+
105
+ it('removeAssetId() takes off a worn asset on logged in user\'s avatar', async () => {
106
+ await expect(removeAssetId(1989194006)).resolves.not.toThrow()
107
+ })
108
+
109
+ it('setAvatarBodyColors() sets body colors to selected colors', () => {
110
+ return setAvatarBodyColors(194, 37, 194, 194, 102, 102).then(() => {
111
+ return getCurrentAvatar().then((res) => {
112
+ expect(res.bodyColors).toEqual({
113
+ headColorId: 194,
114
+ torsoColorId: 37,
115
+ rightArmColorId: 194,
116
+ leftArmColorId: 194,
117
+ rightLegColorId: 102,
118
+ leftLegColorId: 102
119
+ })
120
+ })
121
+ })
122
+ })
123
+
124
+ it('setAvatarScales() sets avatar scales', () => {
125
+ return setAvatarScales(1, 1, 1, 1, 0, 0).then(() => {
126
+ return getCurrentAvatar().then((res) => {
127
+ expect(res.scales).toEqual({
128
+ height: 1,
129
+ width: 1,
130
+ head: 1,
131
+ depth: 1,
132
+ proportion: 0,
133
+ bodyType: 0
134
+ })
135
+ })
136
+ })
137
+ })
138
+
139
+ it('setPlayerAvatarType() sets avatar body type', () => {
140
+ return setPlayerAvatarType('R6').then(() => {
141
+ return getCurrentAvatar().then((res) => {
142
+ expect(res.playerAvatarType).toBe('R6')
143
+ })
144
+ })
145
+ })
146
+
147
+ it('setWearingAssets() sets the player worn asset ID list to whatever is provided', async () => {
148
+ await expect(setWearingAssets([63690008,
149
+ 86498048,
150
+ 86500008,
151
+ 86500036,
152
+ 86500054,
153
+ 86500064,
154
+ 86500078,
155
+ 144075659,
156
+ 144076358,
157
+ 144076760
158
+ ])).resolves.not.toThrow()
159
+ })
160
+
161
+ it('wearAssetId() wears the asset ID provided on the currently logged in user\'s avatar', async () => {
162
+ await expect(wearAssetId(1989194006)).resolves.not.toThrow()
163
+ })
164
+ })
@@ -0,0 +1,96 @@
1
+ const { getAwardedTimestamps, getBadgeInfo, getGameBadges, getPlayerBadges, setCookie } = require('../lib')
2
+
3
+ beforeAll(() => {
4
+ return new Promise(resolve => {
5
+ setCookie(process.env.COOKIE).then(() => {
6
+ resolve()
7
+ })
8
+ })
9
+ })
10
+
11
+ describe('Badges Methods', () => {
12
+ it('getAwardedTimestamps() returns when badges were awarded to a player', () => {
13
+ return getAwardedTimestamps(64679301, [459405541]).then((res) => {
14
+ return expect(res).toMatchObject({
15
+ data: expect.any(Array)
16
+ })
17
+ })
18
+ })
19
+
20
+ it('getBadgeInfo() returns information on the provided badge ID', () => {
21
+ return getBadgeInfo(459405541).then((res) => {
22
+ return expect(res).toMatchObject({
23
+ id: expect.any(Number),
24
+ name: expect.any(String),
25
+ description: expect.any(String),
26
+ enabled: expect.any(Boolean),
27
+ iconImageId: expect.any(Number),
28
+ created: expect.any(Date),
29
+ updated: expect.any(Date),
30
+ statistics: expect.any(Object),
31
+ awardingUniverse: expect.any(Object)
32
+ })
33
+ })
34
+ })
35
+
36
+ it('getGameBadges() returns information on the badges in a game', () => {
37
+ return getGameBadges(66654135).then((res) => {
38
+ return expect(res).toEqual(
39
+ expect.arrayContaining([
40
+ expect.objectContaining({
41
+ id: expect.any(Number),
42
+ name: expect.any(String),
43
+ description: expect.any(String),
44
+ displayName: expect.any(String),
45
+ displayDescription: expect.any(String),
46
+ enabled: expect.any(Boolean),
47
+ iconImageId: expect.any(Number),
48
+ displayIconImageId: expect.any(Number),
49
+ created: expect.any(Date),
50
+ updated: expect.any(Date),
51
+ statistics: expect.objectContaining({
52
+ pastDayAwardedCount: expect.any(Number),
53
+ awardedCount: expect.any(Number),
54
+ winRatePercentage: expect.any(Number)
55
+ }),
56
+ awardingUniverse: expect.objectContaining({
57
+ id: expect.any(Number),
58
+ name: expect.any(String),
59
+ rootPlaceId: expect.any(Number)
60
+ })
61
+ })
62
+ ])
63
+ )
64
+ })
65
+ })
66
+
67
+ it('getPlayerBadges() returns information on badges a player has earned', () => {
68
+ return getPlayerBadges(55549140, 10).then((res) => {
69
+ return expect(res).toEqual(
70
+ expect.arrayContaining([
71
+ expect.objectContaining({
72
+ id: expect.any(Number),
73
+ name: expect.any(String),
74
+ description: expect.any(String),
75
+ displayName: expect.any(String),
76
+ displayDescription: expect.any(String),
77
+ enabled: expect.any(Boolean),
78
+ iconImageId: expect.any(Number),
79
+ displayIconImageId: expect.any(Number),
80
+ awarder: expect.objectContaining({
81
+ id: expect.any(Number),
82
+ type: expect.any(String)
83
+ }),
84
+ statistics: expect.objectContaining({
85
+ pastDayAwardedCount: expect.any(Number),
86
+ awardedCount: expect.any(Number),
87
+ winRatePercentage: expect.any(Number)
88
+ }),
89
+ created: expect.any(Date),
90
+ updated: expect.any(Date)
91
+ })
92
+ ])
93
+ )
94
+ })
95
+ })
96
+ })
@@ -0,0 +1,104 @@
1
+ const { addUsersToConversation, chatSettings, getChatMessages, getConversations, getRolloutSettings, getUnreadConversationCount, getUnreadMessages, getUserConversations, markChatAsRead, markChatAsSeen, multiGetLatestMessages, removeFromGroupConversation, renameGroupConversation, sendChatMessage, setChatUserTyping, start121Conversation, startGroupConversation, setCookie } = require('../lib')
2
+
3
+ beforeAll(() => {
4
+ return new Promise(resolve => {
5
+ setCookie(process.env.COOKIE).then(() => {
6
+ resolve()
7
+ })
8
+ })
9
+ })
10
+
11
+ describe('Chat Methods', () => {
12
+ let newConversationId
13
+
14
+ it('addUsersToConversation() adds additional user(s) to form a group chat', () => {
15
+ return addUsersToConversation(8212952828, [3187412077]).then((res) => {
16
+ if (res && res.conversationId) newConversationId = res.conversationId
17
+
18
+ expect(res).toEqual(
19
+ expect.objectContaining({
20
+ conversationId: expect.any(Number)
21
+ })
22
+ )
23
+ })
24
+ })
25
+
26
+ it('chatSettings() returns chat settings', () => {
27
+ return chatSettings().then((res) => {
28
+ expect(res).toMatchObject({
29
+ chatEnabled: expect.any(Boolean),
30
+ isActiveChatUser: expect.any(Boolean)
31
+ })
32
+ })
33
+ })
34
+
35
+ it('getChatMessages() returns chat messages', async () => {
36
+ await expect(getChatMessages(8212952828)).resolves.not.toThrow()
37
+ })
38
+
39
+ it('getConversations() returns chat conversations that fit the provided IDs', async () => {
40
+ await expect(getConversations([8212952828])).resolves.not.toThrow()
41
+ })
42
+
43
+ it('getRolloutSettings() returns rollout settings for chat features', async () => {
44
+ await expect(getRolloutSettings(['LuaChat', 'Party'])).resolves.not.toThrow()
45
+ })
46
+
47
+ it('getUnreadConversationCount() returns number of unread conversations', () => {
48
+ return getUnreadConversationCount().then((res) => {
49
+ expect(res).toMatchObject({
50
+ count: expect.any(Number)
51
+ })
52
+ })
53
+ })
54
+
55
+ it('getUnreadMessages() returns unread messages in a given conversation', async () => {
56
+ await expect(getUnreadMessages([8212952828])).resolves.not.toThrow()
57
+ })
58
+
59
+ it('getUserConversations() returns all conversations the logged in user is in', async () => {
60
+ await expect(getUserConversations()).resolves.not.toThrow()
61
+ })
62
+
63
+ it('markChatAsRead() marks a conversation\'s messages as read to the specified message', async () => {
64
+ await expect(markChatAsRead(8212952828, 'e775e103-876f-4332-84ab-1ea14f326d39')).resolves.not.toThrow()
65
+ })
66
+
67
+ it('markChatAsSeen() marks the conversations provided as seen', async () => {
68
+ await expect(markChatAsSeen([8212952828])).resolves.not.toThrow()
69
+ })
70
+
71
+ it('multiGetLatestMessages() returns the latest messages corresponding to the given list of conversation IDs', async () => {
72
+ await expect(multiGetLatestMessages([8212952828])).resolves.not.toThrow()
73
+ })
74
+
75
+ it('removeFromGroupConversation() removes a user from a given conversation', async () => {
76
+ await expect(removeFromGroupConversation(newConversationId, 3187412077)).resolves.not.toThrow()
77
+ })
78
+
79
+ it('renameGroupConversation() renames a group conversation', async () => {
80
+ await expect(renameGroupConversation(newConversationId, 'noblox testing')).resolves.not.toThrow()
81
+ })
82
+
83
+ it('sendChatMessage() sends a chat message with provided content', async () => {
84
+ await expect(sendChatMessage(newConversationId, 'This is a test.')).resolves.not.toThrow()
85
+ })
86
+
87
+ it('setChatUserTyping() toggles typing status', async () => {
88
+ return setChatUserTyping(newConversationId, false).then((res) => {
89
+ expect(res).toMatchObject({ resultType: 'Success' })
90
+ })
91
+ })
92
+
93
+ it('start121Conversation() starts a conversation with another user', async () => {
94
+ await expect(start121Conversation(3187412077)).resolves.not.toThrow()
95
+ })
96
+
97
+ // TODO: startCloudEditConversation
98
+
99
+ it('startGroupConversation() opens a conversation with multiple people in it', () => {
100
+ return startGroupConversation([55549140, 3187412077], 'noblox test 2').then((res) => {
101
+ expect(res).toMatchObject({ resultType: 'Success' })
102
+ })
103
+ })
104
+ })
@@ -0,0 +1,105 @@
1
+ const { deleteDatastoreEntry, getDatastoreEntry, getDatastoreEntryVersions, setDatastoreEntry, getDatastoreKeys, getDatastores, incrementDatastoreEntry, setAPIKey } = require('../lib')
2
+
3
+ beforeAll(() => {
4
+ setAPIKey(process.env.API_KEY)
5
+ })
6
+
7
+ describe('Data Store Methods', () => {
8
+ it('setDatastoreEntry() sets a datastore entry to the specified value', async () => {
9
+ return setDatastoreEntry({ universeId: 79354837, datastoreName: 'noblox_testing', entryKey: 'test1', body: 230, robloxEntryUserIDs: [55549140] }).then((res) => {
10
+ expect(res).toMatchObject({
11
+ version: expect.any(String),
12
+ deleted: expect.any(Boolean),
13
+ contentLength: expect.any(Number),
14
+ createdTime: expect.any(Date),
15
+ objectCreatedTime: expect.any(Date)
16
+ })
17
+ })
18
+ })
19
+
20
+ it('getDatastores() returns all datastores in a universe', async () => {
21
+ return getDatastores(79354837).then((res) => {
22
+ return expect(res).toMatchObject({
23
+ datastores: expect.arrayContaining([
24
+ expect.objectContaining({
25
+ name: expect.any(String),
26
+ createdTime: expect.any(Date)
27
+ })
28
+ ]),
29
+ nextPageCursor: expect.toBeOneOf([expect.any(String), null])
30
+ })
31
+ })
32
+ })
33
+
34
+ it('getDatastoreEntry() returns a datastore entry', async () => {
35
+ return getDatastoreEntry({ universeId: 79354837, datastoreName: 'noblox_testing', entryKey: 'test1' }).then((res) => {
36
+ return expect(res).toMatchObject({
37
+ data: expect.anything(),
38
+ metadata: expect.objectContaining({
39
+ robloxEntryCreatedTime: expect.any(Date),
40
+ lastModified: expect.any(Date),
41
+ robloxEntryVersion: expect.any(String),
42
+ robloxEntryAttributes: expect.toBeOneOf([expect.any(String), undefined]),
43
+ robloxEntryUserIDs: expect.toBeOneOf([expect.any(String), undefined]),
44
+ contentMD5: expect.any(String),
45
+ contentLength: expect.any(Number)
46
+ })
47
+ })
48
+ })
49
+ })
50
+
51
+ it('getDatastoreKeys() returns all the keys in a datastore', async () => {
52
+ return getDatastoreKeys({ universeId: 79354837, datastoreName: 'noblox_testing' }).then((res) => {
53
+ return expect(res).toMatchObject({
54
+ keys: expect.arrayContaining([
55
+ expect.objectContaining({
56
+ scope: expect.any(String),
57
+ key: expect.any(String)
58
+ })
59
+ ]),
60
+ nextPageCursor: expect.any(String)
61
+ })
62
+ })
63
+ })
64
+
65
+ it('incrementDatastoreEntry() increments an entry by one', async () => {
66
+ await setDatastoreEntry({ universeId: 79354837, datastoreName: 'noblox_testing', entryKey: 'test1', body: 230, robloxEntryUserIDs: [55549140] })
67
+ return incrementDatastoreEntry({ universeId: 79354837, datastoreName: 'noblox_testing', entryKey: 'test1', incrementBy: 1 }).then((res) => {
68
+ return expect(res).toMatchObject({
69
+ data: 231,
70
+ metadata: expect.objectContaining({
71
+ robloxEntryCreatedTime: expect.any(Date),
72
+ lastModified: expect.any(Date),
73
+ robloxEntryVersion: expect.any(String),
74
+ robloxEntryAttributes: expect.toBeOneOf([expect.any(String), undefined]),
75
+ robloxEntryUserIDs: expect.toBeOneOf([expect.any(String), undefined]),
76
+ contentMD5: expect.any(String),
77
+ contentLength: expect.any(Number)
78
+ })
79
+ })
80
+ })
81
+ })
82
+
83
+ it('getDatastoreEntryVersions() returns versions of an entry in a datastore', async () => {
84
+ return getDatastoreEntryVersions({ universeId: 79354837, datastoreName: 'noblox_testing', entryKey: 'test1' }).then((res) => {
85
+ return expect(res).toMatchObject({
86
+ versions: expect.arrayContaining([
87
+ expect.objectContaining({
88
+ version: expect.any(String),
89
+ deleted: expect.any(Boolean),
90
+ contentLength: expect.any(Number),
91
+ createdTime: expect.any(Date),
92
+ objectCreatedTime: expect.any(Date)
93
+ })
94
+ ]),
95
+ nextPageCursor: expect.any(String)
96
+ })
97
+ })
98
+ })
99
+
100
+ it('deleteDatastoreEntry() deletes an entry from the datastore', async () => {
101
+ await setDatastoreEntry({ universeId: 79354837, datastoreName: 'noblox_testing', entryKey: 'test2', body: 'delete me!' })
102
+
103
+ return await expect(deleteDatastoreEntry({ universeId: 79354837, datastoreName: 'noblox_testing', entryKey: 'test2' })).resolves.not.toThrow()
104
+ })
105
+ })
@@ -0,0 +1,53 @@
1
+ const { canManage, configureItem, getProductInfo, updateUniverse, updateUniverseAccess, setCookie } = require('../lib')
2
+
3
+ beforeAll(() => {
4
+ return new Promise(resolve => {
5
+ setCookie(process.env.COOKIE).then(() => {
6
+ resolve()
7
+ })
8
+ })
9
+ })
10
+
11
+ describe('Develop Methods', () => {
12
+ it('canManage() checks if a user can manage an asset', () => {
13
+ return canManage(2416399685, 6792044666).then((res) => {
14
+ return expect(res).toBe(true)
15
+ })
16
+ })
17
+
18
+ it('configureItem() successfully configures an item user owns', () => {
19
+ return configureItem(1989194006, 'Main t-shirt', 'Uploaded by me').then(() => {
20
+ return getProductInfo(1989194006).then((res) => {
21
+ return expect(res).toMatchObject({
22
+ Name: 'Main t-shirt',
23
+ Description: 'Uploaded by me'
24
+ })
25
+ })
26
+ })
27
+ })
28
+
29
+ it('updateUniverse() should update a universe with the provided settings', () => {
30
+ return updateUniverse(79354837, { description: 'Testing 1234' }).then((res) => {
31
+ return expect(res).toEqual(
32
+ expect.objectContaining({
33
+ genre: expect.any(String),
34
+ id: expect.any(Number),
35
+ isArchived: expect.any(Boolean),
36
+ isForSale: expect.any(Boolean),
37
+ isFriendsOnly: expect.any(Boolean),
38
+ name: expect.any(String),
39
+ playableDevices: expect.any(Array),
40
+ price: expect.any(Number),
41
+ universeAnimationType: expect.any(String),
42
+ universeAvatarType: expect.any(String),
43
+ universeCollisionType: expect.any(String),
44
+ universeJointPositioningType: expect.any(String)
45
+ })
46
+ )
47
+ })
48
+ })
49
+
50
+ it('updateUniverseAccess() should update a universe\'s public access setting.', async () => {
51
+ await expect(updateUniverseAccess(79354837, true)).resolves.not.toThrow()
52
+ })
53
+ })