Skip to content

Commit 655787c

Browse files
committed
fix: Fix existing tests
1 parent 384cd5f commit 655787c

File tree

10 files changed

+233
-231
lines changed

10 files changed

+233
-231
lines changed

src/binder/src/Shared/BinderProvider.spec.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("BinderProvider.new()", function()
2626
end))
2727
end)
2828

29-
expect(provider).to.be.a("table")
29+
expect(provider).toEqual(expect.any("table"))
3030
end)
3131

3232
it("should initialize", function()
@@ -36,8 +36,10 @@ describe("BinderProvider.new()", function()
3636
end)
3737

3838
it("should contain the binder", function()
39-
expect(provider.Test).to.be.a("table")
39+
expect(provider.Test).toEqual(expect.any("table"))
4040
end)
4141

42-
provider:Destroy()
42+
if provider then
43+
provider:Destroy()
44+
end
4345
end)

src/clienttranslator/src/Shared/Numbers/NumberLocalizationUtils.spec.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ local it = Jest.Globals.it
1010

1111
local function checkLocale(locale, responseMapping)
1212
for input, output in pairs(responseMapping) do
13-
expect(NumberLocalizationUtils.localize(input, locale)).to.equal(output)
13+
expect(NumberLocalizationUtils.localize(input, locale)).toBe(output)
1414
end
1515
end
1616

@@ -36,21 +36,21 @@ describe("NumberLocalizationUtils.localize", function()
3636
-- local logs = Logging.capture(function()
3737
-- checkValid_en_zh("bad_locale")
3838
-- end)
39-
-- expect(string.match(logs.warnings[1], "^Warning: Locale not found:") ~= nil).to.equal(true)
39+
-- expect(string.match(logs.warnings[1], "^Warning: Locale not found:") ~= nil).toBe(true)
4040
-- end)
4141

4242
-- it("should default to en-us when locale is nil", function()
4343
-- local logs = Logging.capture(function()
4444
-- checkValid_en_zh(nil)
4545
-- end)
46-
-- expect(string.match(logs.warnings[1], "^Warning: Locale not found:") ~= nil).to.equal(true)
46+
-- expect(string.match(logs.warnings[1], "^Warning: Locale not found:") ~= nil).toBe(true)
4747
-- end)
4848

4949
-- it("should default to en-us when locale is empty", function()
5050
-- local logs = Logging.capture(function()
5151
-- checkValid_en_zh("")
5252
-- end)
53-
-- expect(string.match(logs.warnings[1], "^Warning: Locale not found:") ~= nil).to.equal(true)
53+
-- expect(string.match(logs.warnings[1], "^Warning: Locale not found:") ~= nil).toBe(true)
5454
-- end)
5555

5656
it("should localize correctly. (en-us)", function()
@@ -106,7 +106,7 @@ describe("NumberLocalizationUtils.abbreviate", function()
106106
}
107107

108108
for input, output in pairs(roundToZeroMap) do
109-
expect(NumberLocalizationUtils.abbreviate(input, "en-us", RoundingBehaviourTypes.TRUNCATE)).to.equal(output)
109+
expect(NumberLocalizationUtils.abbreviate(input, "en-us", RoundingBehaviourTypes.TRUNCATE)).toBe(output)
110110
end
111111
end)
112112
end)

src/elo/src/Shared/EloUtils.spec.lua

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).bootstrapStory(script)
77

8+
local EloMatchResult = require("EloMatchResult")
89
local EloUtils = require("EloUtils")
910
local Jest = require("Jest")
1011

@@ -28,11 +29,11 @@ describe("EloUtils.getNewElo", function()
2829
playerRating,
2930
opponentRating,
3031
{
31-
EloUtils.MatchResult.PLAYER_ONE_WIN;
32+
EloMatchResult.PLAYER_ONE_WIN;
3233
})
3334

34-
expect(newPlayerWinRating > playerRating).to.equal(true)
35-
expect(newOpponentWinRating < opponentRating).to.equal(true)
35+
expect(newPlayerWinRating > playerRating).toBe(true)
36+
expect(newOpponentWinRating < opponentRating).toBe(true)
3637
end)
3738

3839
it("should change on a loss", function()
@@ -41,11 +42,11 @@ describe("EloUtils.getNewElo", function()
4142
playerRating,
4243
opponentRating,
4344
{
44-
EloUtils.MatchResult.PLAYER_TWO_WIN;
45+
EloMatchResult.PLAYER_TWO_WIN;
4546
})
4647

47-
expect(newPlayerLossRating < playerRating).to.equal(true)
48-
expect(newOpponentLossRating > opponentRating).to.equal(true)
48+
expect(newPlayerLossRating < playerRating).toBe(true)
49+
expect(newOpponentLossRating > opponentRating).toBe(true)
4950
end)
5051

5152
it("should change on a draw", function()
@@ -54,26 +55,26 @@ describe("EloUtils.getNewElo", function()
5455
playerRating,
5556
opponentRating,
5657
{
57-
EloUtils.MatchResult.DRAW;
58+
EloMatchResult.DRAW;
5859
})
5960

60-
expect(newPlayerDrawRating > playerRating).to.equal(true)
61-
expect(newOpponentDrawRating < opponentRating).to.equal(true)
61+
expect(newPlayerDrawRating > playerRating).toBe(true)
62+
expect(newOpponentDrawRating < opponentRating).toBe(true)
6263
end)
6364

6465
it("should change more on an unexpected win then a loss", function()
6566
local winChange = math.abs(playerRating - newPlayerWinRating)
6667
local drawChange = math.abs(playerRating - newPlayerDrawRating)
6768
local lossChange = math.abs(playerRating - newPlayerLossRating)
6869

69-
expect(winChange > lossChange).to.equal(true)
70-
expect(winChange > drawChange ).to.equal(true)
71-
expect(drawChange > lossChange).to.equal(true)
70+
expect(winChange > lossChange).toBe(true)
71+
expect(winChange > drawChange ).toBe(true)
72+
expect(drawChange > lossChange).toBe(true)
7273
end)
7374

7475
it("should compute percentile as 0.5", function()
7576
local percentile = EloUtils.getPercentile(config, 1400)
7677

77-
expect(percentile).to.equal(0.5)
78+
expect(percentile).toBe(0.5)
7879
end)
7980
end)

src/experiencecalculator/src/Shared/ExperienceUtils.spec.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@ local config = ExperienceUtils.createExperienceConfig({
1818
describe("ExperienceUtils.getLevel", function()
1919
it("should return a level", function()
2020
local level = ExperienceUtils.getLevel(config, 0)
21-
expect(level).to.equal(1)
21+
expect(level).toBe(1)
2222

2323
level = ExperienceUtils.getLevel(config, 399)
24-
expect(level).to.equal(1)
24+
expect(level).toBe(1)
2525

2626
level = ExperienceUtils.getLevel(config, 400)
27-
expect(level).to.equal(2)
27+
expect(level).toBe(2)
2828
end)
2929
end)
3030

3131
describe("ExperienceUtils.experienceFromLevel", function()
3232
it("should return experience", function()
3333
local experience = ExperienceUtils.experienceFromLevel(config, 1)
34-
expect(experience).to.equal(0)
34+
expect(experience).toBe(0)
3535

3636
experience = ExperienceUtils.experienceFromLevel(config, 2)
37-
expect(experience).to.equal(400)
37+
expect(experience).toBe(400)
3838

3939
experience = ExperienceUtils.experienceFromLevel(config, 3)
40-
expect(experience).to.equal(1200)
40+
expect(experience).toBe(1200)
4141
end)
4242
end)

0 commit comments

Comments
 (0)