Skip to content

Commit 2aa38a2

Browse files
committed
Fix tests
1 parent 0e5538c commit 2aa38a2

3 files changed

Lines changed: 53 additions & 23 deletions

File tree

spec/System/TestTradeQueryCurrency_spec.lua

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,6 @@ describe("TradeQuery Currency Conversion", function()
2323
end)
2424
end)
2525

26-
describe("ReduceOutput", function()
27-
it("uses selected minion stats for weighted result comparison", function()
28-
mock_tradeQuery.statSortSelectionList = { { stat = "AverageDamage" } }
29-
30-
local result = mock_tradeQuery:ReduceOutput({
31-
AverageDamage = 10,
32-
Life = 100,
33-
Minion = {
34-
AverageDamage = 250,
35-
Life = 200,
36-
},
37-
})
38-
39-
assert.are.equals(250, result.AverageDamage)
40-
assert.is_nil(result.Life)
41-
end)
42-
end)
43-
4426
describe("PriceBuilderProcessPoENinjaResponse", function()
4527
-- Pass: Processes without error, restoring map while adding a notice
4628
-- Fail: Corrupts map or crashes, indicating fragile API response handling, breaking future conversions

spec/System/TestTradeQueryGenerator_spec.lua

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,31 @@ describe("TradeQueryGenerator", function()
3535
assert.are.equal(result, 100)
3636
end)
3737

38-
it("uses minion output for non-FullDPS stats when minion output is available", function()
39-
local baseOutput = { AverageDamage = 10, Minion = { AverageDamage = 100 } }
40-
local newOutput = { AverageDamage = 10, Minion = { AverageDamage = 250 } }
41-
local statWeights = { { stat = "AverageDamage", weightMult = 1 } }
38+
it("uses minion output for non-FullDPS stats when minion output is desired", function()
39+
local baseOutput = { Life = 10, Minion = { Life = 100 } }
40+
local newOutput = { Life = 10, Minion = { Life = 250 } }
41+
local statWeights = { { stat = "MinionLife", weightMult = 1 } }
4242
data.misc.maxStatIncrease = 1000
4343

4444
local result = mock_queryGen.WeightedRatioOutputs(baseOutput, newOutput, statWeights)
4545

4646
assert.are.equal(result, 2.5)
4747
end)
4848

49-
it("uses player output for FullDPS even when minion output is available", function()
49+
it("uses lower is better stats correctly", function()
50+
local baseOutput = { MaxHit = 100 }
51+
local newOutput = { MaxHit = 10 }
52+
local statWeights = { { stat = "MaxHit", weightMult = 1, transform = function(number) return -number end } }
53+
data.misc.maxStatIncrease = 1000
54+
55+
local result = mock_queryGen.WeightedRatioOutputs(baseOutput, newOutput, statWeights)
56+
57+
local close_enough = (result - -0.1) < 0.0001
58+
assert.True(close_enough)
59+
end)
60+
61+
it("uses player and minion output for FullDPS", function()
62+
-- minion output gets assigned to the player's full dps in reality
5063
local baseOutput = { FullDPS = 100, Minion = { FullDPS = 100 } }
5164
local newOutput = { FullDPS = 250, Minion = { FullDPS = 1000 } }
5265
local statWeights = { { stat = "FullDPS", weightMult = 1 } }
@@ -57,6 +70,16 @@ describe("TradeQueryGenerator", function()
5770
assert.are.equal(result, 2.5)
5871
end)
5972

73+
it("uses player output for non-FullDPS even when minion output is available", function()
74+
local baseOutput = { Life = 100, Minion = { Life = 100 } }
75+
local newOutput = { Life = 250, Minion = { Life = 1000 } }
76+
local statWeights = { { stat = "Life", weightMult = 1 } }
77+
data.misc.maxStatIncrease = 1000
78+
79+
local result = mock_queryGen.WeightedRatioOutputs(baseOutput, newOutput, statWeights)
80+
assert.are.equal(result, 2.5)
81+
end)
82+
6083
it("uses the fallback DPS ratio once when FullDPS is unavailable", function()
6184
local baseOutput = { Minion = { TotalDPS = 10, TotalDotDPS = 0, CombinedDPS = 10 } }
6285
local newOutput = { Minion = { TotalDPS = 25, TotalDotDPS = 0, CombinedDPS = 25 } }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
describe("TradeQuery", function ()
2+
local mock_tradeQuery
3+
4+
before_each(function()
5+
mock_tradeQuery = new("TradeQuery", { itemsTab = {} })
6+
end)
7+
8+
describe("ReduceOutput", function()
9+
it("uses selected minion stats for weighted result comparison", function()
10+
mock_tradeQuery.statSortSelectionList = { { stat = "AverageDamage" } }
11+
12+
local result = mock_tradeQuery:ReduceOutput({
13+
AverageDamage = 10,
14+
Life = 100,
15+
Minion = {
16+
AverageDamage = 250,
17+
Life = 200,
18+
},
19+
})
20+
21+
assert.are.equals(260, result.AverageDamage)
22+
assert.is_nil(result.Life)
23+
end)
24+
end)
25+
end)

0 commit comments

Comments
 (0)