-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
971 additions
and
794 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
use_tab: true | ||
indent_width: 1 | ||
keep_simple_function_one_line: false | ||
break_before_functioncall_rp: true | ||
break_after_operator: false | ||
break_after_operator: false | ||
column_limit: 120 | ||
chop_down_table: true | ||
extra_sep_at_table_end: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
require "busted.runner"() | ||
|
||
insulate("AddonLoader", function() | ||
it("should not crash", function() | ||
assert.has_no.errors( | ||
function() | ||
loadfile(".specs/AddonLoader.lua")().LoadToc("RCLootCouncil.toc") | ||
end | ||
) | ||
end) | ||
it("should not crash", function() | ||
assert.has_no.errors(function() loadfile(".specs/AddonLoader.lua")().LoadToc("RCLootCouncil.toc") end) | ||
end) | ||
end) | ||
|
||
|
||
insulate("AddonLoader", function() | ||
it("should load RCLootCouncil", function() | ||
loadfile(".specs/AddonLoader.lua")().LoadToc("RCLootCouncil.toc") | ||
assert.truthy(_G.RCLootCouncil) | ||
end) | ||
it("should load RCLootCouncil", function() | ||
loadfile(".specs/AddonLoader.lua")().LoadToc("RCLootCouncil.toc") | ||
assert.truthy(_G.RCLootCouncil) | ||
end) | ||
end) | ||
|
||
insulate("AddonLoader", function() | ||
it("should load files without errors", function() | ||
local s = spy.on(_G, "_errorhandler") | ||
loadfile(".specs/AddonLoader.lua")().LoadToc("RCLootCouncil.toc") | ||
pending("Will error out, but it's hard to fix at this point") | ||
WoWAPI_FireEvent("ADDON_LOADED", "RCLootCouncil") | ||
assert.spy(s).was_not.called() | ||
end) | ||
it("should load files without errors", function() | ||
local s = spy.on(_G, "_errorhandler") | ||
loadfile(".specs/AddonLoader.lua")().LoadToc("RCLootCouncil.toc") | ||
WoWAPI_FireEvent("ADDON_LOADED", "RCLootCouncil") | ||
assert.spy(s).was_not.called() | ||
end) | ||
|
||
it("should be enabled without issues", function() | ||
local s = spy.on(_G, "_errorhandler") | ||
_G.IsLoggedIn = spy.new(function() return true end) | ||
WoWAPI_FireEvent("PLAYER_LOGIN", "RCLootCouncil") | ||
assert.truthy(_G.RCLootCouncil) | ||
assert.True(_G.RCLootCouncil.TradeUI:IsEnabled()) | ||
assert.spy(s).was_not.called() | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,132 +1,91 @@ | ||
require "busted.runner"() | ||
local addon = { | ||
realmName = "Realm1", | ||
db = {global = {log = {}, cache = {}}, profile = {}}, | ||
defaults = {global = {logMaxEntries = 2000}} | ||
realmName = "Realm1", | ||
db = {global = {log = {}, cache = {}}, profile = {}}, | ||
defaults = {global = {logMaxEntries = 2000}} | ||
} | ||
loadfile(".specs/AddonLoader.lua")(nil, nil, addon).LoadArray { | ||
[[Libs\LibStub\LibStub.lua]], | ||
[[Libs\CallbackHandler-1.0\CallbackHandler-1.0.xml]], | ||
[[Libs\AceComm-3.0\AceComm-3.0.xml]], | ||
[[Libs\AceLocale-3.0\AceLocale-3.0.xml]], | ||
[[Libs\AceSerializer-3.0\AceSerializer-3.0.xml]], | ||
[[Libs\AceEvent-3.0\AceEvent-3.0.xml]], | ||
[[Locale\enUS.lua]], | ||
[[Core\Constants.lua]], | ||
[[Core\Defaults.lua]], | ||
[[Classes\Core.lua]], | ||
[[Classes\Lib\RxLua\embeds.xml]], | ||
[[Libs\LibDeflate\LibDeflate.lua]], | ||
[[Classes\Utils\Log.lua]], | ||
[[Classes\Utils\TempTable.lua]], | ||
[[Classes\Services\ErrorHandler.lua]], | ||
[[Locale\enUS.lua]], | ||
[[Utils\Utils.lua]], | ||
[[Classes\Data\Player.lua]], | ||
[[Classes\Services\Comms.lua]], | ||
[[Classes\Data\MLDB.lua]] | ||
[[Libs\LibStub\LibStub.lua]], | ||
[[Libs\CallbackHandler-1.0\CallbackHandler-1.0.xml]], | ||
[[Libs\AceComm-3.0\AceComm-3.0.xml]], | ||
[[Libs\AceLocale-3.0\AceLocale-3.0.xml]], | ||
[[Libs\AceSerializer-3.0\AceSerializer-3.0.xml]], | ||
[[Libs\AceEvent-3.0\AceEvent-3.0.xml]], | ||
[[Locale\enUS.lua]], | ||
[[Core\Constants.lua]], | ||
[[Core\Defaults.lua]], | ||
[[Classes\Core.lua]], | ||
[[Classes\Lib\RxLua\embeds.xml]], | ||
[[Libs\LibDeflate\LibDeflate.lua]], | ||
[[Classes\Utils\Log.lua]], | ||
[[Classes\Utils\TempTable.lua]], | ||
[[Classes\Services\ErrorHandler.lua]], | ||
[[Locale\enUS.lua]], | ||
[[Utils\Utils.lua]], | ||
[[Classes\Data\Player.lua]], | ||
[[Classes\Services\Comms.lua]], | ||
[[Classes\Data\MLDB.lua]] | ||
} | ||
|
||
function addon:Getdb() | ||
return self.db.profile | ||
return self.db.profile | ||
end | ||
|
||
setmetatable( | ||
addon.db.profile, | ||
{ | ||
__index = addon.defaults.profile | ||
} | ||
) | ||
setmetatable(addon.db.profile, {__index = addon.defaults.profile}) | ||
|
||
describe( | ||
"#Data #MLDB", | ||
function() | ||
---@type Data.MLDB | ||
local MLDB = addon.Require "Data.MLDB" | ||
local AceSer = LibStub("AceSerializer-3.0") | ||
describe( | ||
"init", | ||
function() | ||
it( | ||
"should contain basic functions", | ||
function() | ||
assert.is.Function(MLDB.GetForTransmit) | ||
assert.is.Function(MLDB.RestoreFromTransmit) | ||
assert.is.Function(MLDB.Send) | ||
assert.is.Function(MLDB.Get) | ||
assert.is.Function(MLDB.Update) | ||
end | ||
) | ||
end | ||
) | ||
describe( | ||
"functions", | ||
function() | ||
before_each( | ||
function() | ||
-- Always use a fresh copy | ||
loadfile([[Core\Defaults.lua]])(nil, addon) | ||
end | ||
) | ||
describe("#Data #MLDB", function() | ||
---@type Data.MLDB | ||
local MLDB = addon.Require "Data.MLDB" | ||
local AceSer = LibStub("AceSerializer-3.0") | ||
describe("init", function() | ||
it("should contain basic functions", function() | ||
assert.is.Function(MLDB.GetForTransmit) | ||
assert.is.Function(MLDB.RestoreFromTransmit) | ||
assert.is.Function(MLDB.Send) | ||
assert.is.Function(MLDB.Get) | ||
assert.is.Function(MLDB.Update) | ||
end) | ||
end) | ||
describe("functions", function() | ||
before_each(function() | ||
-- Always use a fresh copy | ||
loadfile([[Core\Defaults.lua]])(nil, addon) | ||
end) | ||
|
||
it( | ||
"should get MLDB", | ||
function() | ||
local mldb = MLDB:Get() | ||
assert.are.equal(60, mldb.timeout) | ||
assert.are.equal(true, mldb.selfVote) | ||
end | ||
) | ||
it("should get MLDB", function() | ||
local mldb = MLDB:Get() | ||
assert.are.equal(60, mldb.timeout) | ||
assert.are.equal(true, mldb.selfVote) | ||
end) | ||
|
||
it( | ||
"should compress the MLDB", | ||
function() | ||
local mldb = MLDB:Get() | ||
local forTransmit = MLDB:GetForTransmit() | ||
assert.are.equal(60, forTransmit["|12"]) -- timeout | ||
assert.True(#AceSer:Serialize(mldb) > #AceSer:Serialize(forTransmit)) | ||
end | ||
) | ||
it("should compress the MLDB", function() | ||
local mldb = MLDB:Get() | ||
local forTransmit = MLDB:GetForTransmit() | ||
assert.are.equal(60, forTransmit["|12"]) -- timeout | ||
assert.True(#AceSer:Serialize(mldb) > #AceSer:Serialize(forTransmit)) | ||
end) | ||
|
||
it( | ||
"should restore a transmitted MLDB", | ||
function() | ||
local mldb = MLDB:Get() | ||
local restored = MLDB:RestoreFromTransmit(MLDB:GetForTransmit()) | ||
assert.are.same(mldb, restored) | ||
end | ||
) | ||
it("should restore a transmitted MLDB", function() | ||
local mldb = MLDB:Get() | ||
local restored = MLDB:RestoreFromTransmit(MLDB:GetForTransmit()) | ||
assert.are.same(mldb, restored) | ||
end) | ||
|
||
it( | ||
"should update mldb", | ||
function() | ||
local mldb1 = MLDB:Get() | ||
addon.db.profile.buttons.NEW = { | ||
numButtons = 1, | ||
{text = "Test"} | ||
} | ||
addon.db.profile.responses.NEW = { | ||
{text = "Tester"} | ||
} | ||
local mldb2 = MLDB:Update() | ||
assert.are_not.same(mldb1, mldb2) | ||
assert.are.equal(1, #mldb2.buttons.NEW) | ||
assert.are.equal("Test", mldb2.buttons.NEW[1].text) | ||
end | ||
) | ||
it( | ||
"should handle random added values", | ||
function() | ||
assert.has_no.errors( | ||
function() | ||
local mldb = MLDB:Get() | ||
mldb.newValue = true | ||
MLDB:GetForTransmit(mldb) | ||
end | ||
) | ||
end | ||
) | ||
end | ||
) | ||
end | ||
) | ||
it("should update mldb", function() | ||
local mldb1 = MLDB:Get() | ||
addon.db.profile.buttons.NEW = {numButtons = 1, {text = "Test"}} | ||
addon.db.profile.responses.NEW = {{text = "Tester"}} | ||
local mldb2 = MLDB:Update() | ||
assert.are_not.same(mldb1, mldb2) | ||
assert.are.equal(1, #mldb2.buttons.NEW) | ||
assert.are.equal("Test", mldb2.buttons.NEW[1].text) | ||
end) | ||
it("should handle random added values", function() | ||
assert.has_no.errors(function() | ||
local mldb = MLDB:Get() | ||
mldb.newValue = true | ||
MLDB:GetForTransmit(mldb) | ||
end) | ||
end) | ||
end) | ||
end) |
Oops, something went wrong.