@@ -58,12 +58,25 @@ describe("TradeQuery Currency Conversion", function()
5858 end )
5959
6060 describe (" GetTotalPriceString" , function ()
61- -- Pass: Sums and formats correctly (e.g., "5 chaos, 10 div")
61+ -- Pass: Sums and formats correctly (e.g., "5 chaos, 10 div", should be most valuable currency first )
6262 -- Fail: Wrong string (e.g., unsorted/missing sums), indicating aggregation bug, misleading users on totals
6363 it (" aggregates prices" , function ()
64- mock_tradeQuery .totalPrice = { { currency = " chaos" , amount = 5 }, { currency = " div" , amount = 10 } }
64+ -- check alphabetical sorting
65+ mock_tradeQuery .totalPrice = { { currency = " chaos" , amount = 5 }, { currency = " div" , amount = 10 }, {currency = " exalted" , amount = 1 } }
6566 local result = mock_tradeQuery :GetTotalPriceString ()
66- assert .are .equal (result , " 5 chaos, 10 div" )
67+ assert .are .equal (result , " 1 exalted, 10 div, 5 chaos" )
68+
69+ -- check if they're sorted according to currency value
70+ mock_tradeQuery .pbLeague = " league"
71+ mock_tradeQuery .pbCurrencyConversion = { league = { chaos = 0.1 , exalted = 0.05 , div = 1 , mirror = 700 } }
72+ local result = mock_tradeQuery :GetTotalPriceString ()
73+ assert .are .equal (result , " 10 div, 5 chaos, 1 exalted" )
74+
75+ -- check that missing currency values don't crash
76+ mock_tradeQuery .pbLeague = " league"
77+ mock_tradeQuery .pbCurrencyConversion = { league = { chaos = 0.1 , exalted = 0.05 , mirror = 700 } }
78+ local result = mock_tradeQuery :GetTotalPriceString ()
79+ assert .True (true )
6780 end )
6881 end )
6982end )
0 commit comments