@@ -30,6 +30,31 @@ describe("TradeHelpers trade hash matching", function()
3030 end )
3131 end )
3232
33+ describe (" findTradeIdOption" , function ()
34+ it (" matches a '#'-valued option and returns its value" , function ()
35+ local tradeId , value = tradeHelpers .findTradeIdOption (" Grants Level 20 Summon Bestial Snake Skill" ,
36+ " explicit" )
37+ assert .equal (" explicit.stat_2878779644" , tradeId )
38+ assert .equal (3 , value )
39+ end )
40+
41+ it (" matches an exact-text option and returns no value" , function ()
42+ local tradeId , value = tradeHelpers .findTradeIdOption (" Allocates Tranquility" , " enchant" )
43+ assert .equal (" enchant.stat_2954116742" , tradeId )
44+ assert .equal (16246 , value )
45+ end )
46+
47+ it (" matches a timeless jewel" , function ()
48+ local tradeId , value = tradeHelpers .findTradeIdOption (
49+ " Bathed in the blood of 666 sacrificed in the name of Doryani" , " explicit" )
50+ assert .equal (" explicit.pseudo_timeless_jewel_doryani" , tradeId )
51+ assert .equal (666 , value )
52+ end )
53+
54+ it (" returns nil for an unmatchable line" , function ()
55+ assert .is_nil (tradeHelpers .findTradeIdOption (" +100 to IQ" , " explicit" ))
56+ end )
57+ end )
3358 describe (" findTradeHash" , function ()
3459 it (" matches a simple mod" , function ()
3560 local ids , value = tradeHelpers .findTradeHash (" +50 to maximum Life" )
0 commit comments