-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathTestPassiveTreeView_spec.lua
More file actions
116 lines (101 loc) · 3.38 KB
/
Copy pathTestPassiveTreeView_spec.lua
File metadata and controls
116 lines (101 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
describe("PassiveTreeView jewel comparison", function()
local viewer
local function newJewel(name, raw)
return {
name = name,
BuildRaw = function()
return raw
end,
}
end
local function setCompareJewel(jewel, allocated)
local itemsTab = {
items = { [2] = jewel },
sockets = { [100] = { selItemId = jewel and 2 or 0 } },
}
viewer.compareSpec = {
allocNodes = { [100] = allocated },
build = { itemsTab = itemsTab },
}
return itemsTab
end
before_each(function()
newBuild()
viewer = build.treeTab.viewer
end)
it("matches jewels by their complete raw representation", function()
local primaryJewel = newJewel("Controller Metamorphosis", "Radius: Small")
local compareJewel = newJewel("Controller Metamorphosis", "Radius: Small")
setCompareJewel(compareJewel, true)
local color = viewer:GetCompareNodeColor(
{ id = 100, type = "Socket", alloc = true },
{ alloc = true },
{ jewels = { [100] = 1 } },
{ itemsTab = { items = { [1] = primaryJewel } } },
"^xFFFFFF"
)
assert.are.equals("^xFFFFFF", color)
end)
it("marks same-name jewels with different variants as changed", function()
local primaryJewel = newJewel("Controller Metamorphosis", "Radius: Small")
local compareJewel = newJewel("Controller Metamorphosis", "Radius: Large")
setCompareJewel(compareJewel, true)
local red, green, blue = viewer:GetCompareNodeColor(
{ id = 100, type = "Socket", alloc = true },
{ alloc = true },
{ jewels = { [100] = 1 } },
{ itemsTab = { items = { [1] = primaryJewel } } },
"^xFFFFFF"
)
assert.are.same({ 0, 0, 1 }, { red, green, blue })
end)
it("shows both full jewel tooltips when allocated socket jewels differ", function()
local primaryJewel = newJewel("Controller Metamorphosis", "Radius: Small")
local compareJewel = newJewel("Controller Metamorphosis", "Radius: Large")
local compareItemsTab = setCompareJewel(compareJewel, true)
local primaryTooltipItems = { }
local compareTooltipItems = { }
local socket = { IsEnabled = function() return false end }
local tooltip = {
AddLine = function() end,
AddSeparator = function() end,
}
local primaryBuild = {
itemsTab = {
GetSocketAndJewelForNodeID = function()
return socket, primaryJewel
end,
AddItemTooltip = function(_, _, item)
table.insert(primaryTooltipItems, item)
end,
},
}
compareItemsTab.AddItemTooltip = function(_, _, item)
table.insert(compareTooltipItems, item)
end
viewer:AddNodeTooltip(tooltip, { id = 100, type = "Socket", alloc = true }, primaryBuild)
assert.are.same({ primaryJewel }, primaryTooltipItems)
assert.are.same({ compareJewel }, compareTooltipItems)
end)
it("shows the compared jewel tooltip when only the compared socket is allocated", function()
local compareJewel = newJewel("Controller Metamorphosis", "Radius: Large")
local compareItemsTab = setCompareJewel(compareJewel, true)
local compareTooltipItems = { }
local tooltip = {
AddLine = function() end,
AddSeparator = function() end,
}
local primaryBuild = {
itemsTab = {
GetSocketAndJewelForNodeID = function()
return { }, nil
end,
},
}
compareItemsTab.AddItemTooltip = function(_, _, item)
table.insert(compareTooltipItems, item)
end
viewer:AddNodeTooltip(tooltip, { id = 100, type = "Socket", alloc = false }, primaryBuild)
assert.are.same({ compareJewel }, compareTooltipItems)
end)
end)