@quenty/playersservicepromises 10.20.0 → 10.21.1
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.
- package/CHANGELOG.md +10 -0
- package/deploy.nevermore.json +10 -0
- package/package.json +6 -3
- package/src/Shared/PlayersServicePromises.lua +6 -0
- package/src/Shared/PlayersServicePromises.spec.lua +56 -0
- package/src/jest.config.lua +3 -0
- package/test/default.project.json +17 -0
- package/test/scripts/Server/ServerMain.server.lua +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [10.21.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/playersservicepromises@10.21.0...@quenty/playersservicepromises@10.21.1) (2026-07-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/playersservicepromises
|
|
9
|
+
|
|
10
|
+
# [10.21.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/playersservicepromises@10.20.0...@quenty/playersservicepromises@10.21.0) (2026-07-23)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- Add baseline player-mock and support across Nevermore for mocked players. ([567d121](https://github.com/Quenty/NevermoreEngine/commit/567d121ffc014b42391554088189a1a6296dda83))
|
|
15
|
+
|
|
6
16
|
# [10.20.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/playersservicepromises@10.19.0...@quenty/playersservicepromises@10.20.0) (2026-07-18)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @quenty/playersservicepromises
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/playersservicepromises",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.21.1",
|
|
4
4
|
"description": "Utility methods for async methods in Players service",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -30,10 +30,13 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@quenty/loader": "10.11.0",
|
|
33
|
-
"@quenty/
|
|
33
|
+
"@quenty/nevermore-test-runner": "1.5.0",
|
|
34
|
+
"@quenty/playermock": "1.1.1",
|
|
35
|
+
"@quenty/promise": "10.21.0",
|
|
36
|
+
"@quentystudios/jest-lua": "3.10.0-quenty.2"
|
|
34
37
|
},
|
|
35
38
|
"publishConfig": {
|
|
36
39
|
"access": "public"
|
|
37
40
|
},
|
|
38
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "5ea0583dedebba6492f9ac6d719d32b45c5543fa"
|
|
39
42
|
}
|
|
@@ -8,6 +8,7 @@ local require = require(script.Parent.loader).load(script)
|
|
|
8
8
|
|
|
9
9
|
local Players = game:GetService("Players")
|
|
10
10
|
|
|
11
|
+
local PlayerMock = require("PlayerMock")
|
|
11
12
|
local Promise = require("Promise")
|
|
12
13
|
|
|
13
14
|
local PlayersServicePromises = {}
|
|
@@ -21,6 +22,11 @@ function PlayersServicePromises.promiseUserIdFromName(name: string): Promise.Pro
|
|
|
21
22
|
assert(type(name) == "string", "Bad name")
|
|
22
23
|
|
|
23
24
|
return Promise.spawn(function(resolve, reject)
|
|
25
|
+
local mockPlayer = PlayerMock.getMockByUsername(name)
|
|
26
|
+
if mockPlayer ~= nil then
|
|
27
|
+
return resolve(PlayerMock.read(mockPlayer, "UserId"))
|
|
28
|
+
end
|
|
29
|
+
|
|
24
30
|
local userId
|
|
25
31
|
local ok, err = pcall(function()
|
|
26
32
|
userId = Players:GetUserIdFromNameAsync(name)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
--[[
|
|
3
|
+
@class PlayersServicePromises.spec.lua
|
|
4
|
+
]]
|
|
5
|
+
|
|
6
|
+
local require = require(script.Parent.loader).load(script)
|
|
7
|
+
|
|
8
|
+
local Workspace = game:GetService("Workspace")
|
|
9
|
+
|
|
10
|
+
local Jest = require("Jest")
|
|
11
|
+
local PlayerMock = require("PlayerMock")
|
|
12
|
+
local PlayersServicePromises = require("PlayersServicePromises")
|
|
13
|
+
local PromiseTestUtils = require("PromiseTestUtils")
|
|
14
|
+
|
|
15
|
+
local describe = Jest.Globals.describe
|
|
16
|
+
local expect = Jest.Globals.expect
|
|
17
|
+
local it = Jest.Globals.it
|
|
18
|
+
|
|
19
|
+
describe("PlayersServicePromises.promiseUserIdFromName against a mock", function()
|
|
20
|
+
it("resolves the mock's UserId by its default Name-derived username", function()
|
|
21
|
+
local player = PlayerMock.new({ UserId = 90071001 })
|
|
22
|
+
player.Parent = Workspace
|
|
23
|
+
|
|
24
|
+
local outcome, userId = PromiseTestUtils.awaitOutcome(PlayersServicePromises.promiseUserIdFromName(player.Name))
|
|
25
|
+
|
|
26
|
+
expect(outcome).toBe("resolved")
|
|
27
|
+
expect(userId).toBe(90071001)
|
|
28
|
+
|
|
29
|
+
player:Destroy()
|
|
30
|
+
end)
|
|
31
|
+
|
|
32
|
+
it("resolves the mock's UserId by an injected username", function()
|
|
33
|
+
local player = PlayerMock.new({ UserId = 90071002 })
|
|
34
|
+
player.Parent = Workspace
|
|
35
|
+
PlayerMock.writeLookup(player, "UserService.GetUserInfosByUserIdsAsync", 0, {
|
|
36
|
+
Id = 90071002,
|
|
37
|
+
Username = "injected_lookup_name",
|
|
38
|
+
DisplayName = "Injected",
|
|
39
|
+
HasVerifiedBadge = false,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
local outcome, userId =
|
|
43
|
+
PromiseTestUtils.awaitOutcome(PlayersServicePromises.promiseUserIdFromName("injected_lookup_name"))
|
|
44
|
+
|
|
45
|
+
expect(outcome).toBe("resolved")
|
|
46
|
+
expect(userId).toBe(90071002)
|
|
47
|
+
|
|
48
|
+
player:Destroy()
|
|
49
|
+
end)
|
|
50
|
+
|
|
51
|
+
it("asserts on a non-string name", function()
|
|
52
|
+
expect(function()
|
|
53
|
+
PlayersServicePromises.promiseUserIdFromName(12345 :: any)
|
|
54
|
+
end).toThrow()
|
|
55
|
+
end)
|
|
56
|
+
end)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "PlayersServicePromisesTest",
|
|
3
|
+
"tree": {
|
|
4
|
+
"$className": "DataModel",
|
|
5
|
+
"ServerScriptService": {
|
|
6
|
+
"$properties": {
|
|
7
|
+
"LoadStringEnabled": true
|
|
8
|
+
},
|
|
9
|
+
"playersservicepromises": {
|
|
10
|
+
"$path": ".."
|
|
11
|
+
},
|
|
12
|
+
"Script": {
|
|
13
|
+
"$path": "scripts/Server"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
--!nonstrict
|
|
2
|
+
local ServerScriptService = game:GetService("ServerScriptService")
|
|
3
|
+
|
|
4
|
+
local root = ServerScriptService.playersservicepromises
|
|
5
|
+
local loader = root:FindFirstChild("LoaderUtils", true).Parent
|
|
6
|
+
local require = require(loader).bootstrapGame(root)
|
|
7
|
+
|
|
8
|
+
local NevermoreTestRunnerUtils = require("NevermoreTestRunnerUtils")
|
|
9
|
+
|
|
10
|
+
if NevermoreTestRunnerUtils.runTestsIfNeededAsync(root) then
|
|
11
|
+
return
|
|
12
|
+
end
|