@@ -53,5 +53,90 @@ describe("TradeQuery", function()
5353 end )
5454 assert .are .equal (0 , # tooltip .lines )
5555 end )
56+
57+ it (" returns early from action button tooltips when filtering clears the selected result" , function ()
58+ local tq = newTradeQuery ({
59+ resultTbl = { [1 ] = { [1 ] = { item_string = " Rarity: RARE\n Behemoth Hold\n Gold Ring" , amount = 1 , currency = " chaos" } } },
60+ sortedResultTbl = { [1 ] = {} },
61+ })
62+ buildRow1Dropdown (tq )
63+ local tooltip = new (" Tooltip" )
64+
65+ assert .has_no .errors (function ()
66+ tq .controls .importButton1 .tooltipFunc (tooltip )
67+ tq .controls .whisperButton1 .tooltipFunc (tooltip )
68+ end )
69+ assert .are .equal (0 , # tooltip .lines )
70+ end )
71+ end )
72+
73+ describe (" attribute requirement result filtering" , function ()
74+ local function newTradeQueryWithOutput (output , slotTbl )
75+ local calcCalls = 0
76+ local tq = new (" TradeQuery" , { itemsTab = {} })
77+ tq .slotTables [1 ] = slotTbl or { slotName = " Ring 1" }
78+ tq .resultTbl = {
79+ [1 ] = {
80+ [1 ] = { item_string = " Rarity: RARE\n Behemoth Hold\n Gold Ring" , amount = 1 , currency = " chaos" },
81+ },
82+ }
83+ tq .sortModes = {
84+ Weight = " (Highest) Weighted Sum" ,
85+ }
86+ tq .itemsTab .build = {
87+ calcsTab = {
88+ GetMiscCalculator = function ()
89+ return function ()
90+ calcCalls = calcCalls + 1
91+ return output
92+ end , {}
93+ end ,
94+ },
95+ }
96+ tq .itemsTab .slots = {
97+ [" Ring 1" ] = {},
98+ }
99+ return tq , function ()
100+ return calcCalls
101+ end
102+ end
103+
104+ it (" filters fetched results that do not meet attribute requirements" , function ()
105+ local tq = newTradeQueryWithOutput ({ ReqStr = 50 , Str = 40 , ReqDex = 0 , Dex = 0 , ReqInt = 0 , Int = 0 })
106+ tq .hideResultsFailingAttributeRequirements = true
107+ local sortedItems = tq :SortFetchResults (1 , tq .sortModes .Weight )
108+ assert .are .equal (0 , # sortedItems )
109+ end )
110+
111+ it (" keeps fetched results that meet attribute requirements" , function ()
112+ local tq = newTradeQueryWithOutput ({ ReqStr = 50 , Str = 60 , ReqDex = 30 , Dex = 30 , ReqInt = 20 , Int = 25 })
113+ tq .hideResultsFailingAttributeRequirements = true
114+ local sortedItems = tq :SortFetchResults (1 , tq .sortModes .Weight )
115+ assert .are .equal (1 , # sortedItems )
116+ assert .are .equal (1 , sortedItems [1 ].index )
117+ end )
118+
119+ it (" filters fetched results that do not meet Omniscience requirements" , function ()
120+ local tq = newTradeQueryWithOutput ({ ReqOmni = 100 , Omni = 80 })
121+ tq .hideResultsFailingAttributeRequirements = true
122+ local sortedItems = tq :SortFetchResults (1 , tq .sortModes .Weight )
123+ assert .are .equal (0 , # sortedItems )
124+ end )
125+
126+ it (" keeps fetched results without recalculating by default" , function ()
127+ local tq , calcCalls = newTradeQueryWithOutput ({ ReqStr = 50 , Str = 40 , ReqDex = 0 , Dex = 0 , ReqInt = 0 , Int = 0 })
128+ local sortedItems = tq :SortFetchResults (1 , tq .sortModes .Weight )
129+ assert .are .equal (1 , # sortedItems )
130+ assert .are .equal (1 , sortedItems [1 ].index )
131+ assert .are .equal (0 , calcCalls ())
132+ end )
133+
134+ it (" does not apply equipment attribute filtering to rows without a replacement slot" , function ()
135+ local tq , calcCalls = newTradeQueryWithOutput ({ ReqStr = 50 , Str = 40 , ReqDex = 0 , Dex = 0 , ReqInt = 0 , Int = 0 }, { slotName = " Megalomaniac" , unique = true })
136+ local sortedItems = tq :SortFetchResults (1 , tq .sortModes .Weight )
137+ assert .are .equal (1 , # sortedItems )
138+ assert .are .equal (1 , sortedItems [1 ].index )
139+ assert .are .equal (0 , calcCalls ())
140+ end )
56141 end )
57142end )
0 commit comments