From d3c51e5db86a349630dfed9b699a88e0e81e252a Mon Sep 17 00:00:00 2001 From: Daniel Kay Date: Sat, 3 Oct 2020 14:18:02 -0700 Subject: [PATCH] Start using busted as a test framework See http://olivinelabs.com/busted/ This will allow new features and eventually all functionality to be unit / functionally tested. To invoke, install busted & run ./busted This will read the .busted file for options and execute all tests. --- .busted | 11 +++++++++++ Locale/en_spec.lua | 31 +++++++++++++++++++++++++++++++ Parser/Parser_spec.lua | 15 +++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 .busted create mode 100644 Locale/en_spec.lua create mode 100644 Parser/Parser_spec.lua diff --git a/.busted b/.busted new file mode 100644 index 0000000..e9f33e0 --- /dev/null +++ b/.busted @@ -0,0 +1,11 @@ +return { + _all = { + }, + default = { + verbose = true, + lpath = "Parser/?.lua;Utils/?.lua;Locale/?.lua", + ROOT = {"."}, + recursive = true, + pattern = "_spec.lua", + }, +} \ No newline at end of file diff --git a/Locale/en_spec.lua b/Locale/en_spec.lua new file mode 100644 index 0000000..b34f77d --- /dev/null +++ b/Locale/en_spec.lua @@ -0,0 +1,31 @@ +describe("pre test", function() + it("should be able to load en", function() + stub(_G, "L") + assert.is.truthy(require('en')) + end) + it("should load constants", function() + assert.is.truthy(require('Enums')) + end) +end) + +describe("en tests", function() + setup(function () + require('en') + require('Enums') + end) + describe("parsing tests", function() + it("should read consts", function() + assert.are.same({"Death","Death"},L["Death"]) + end) + it("should parse basic hit", function() + -- body + input = "Gandalf scored a hit on Balrog for 10 damage to Balrog%." + eventType, initiatorName, targetName, skillName, amount, avoidType, critType, dmgType = L["Parse"](input) + assert.is.equal(event_type.DMG_DEALT,eventType) + assert.is.equal("Gandalf",initiatorName) + assert.is.equal("Balrog", targetName) + assert.is.equal(L["DirectDamage"], skillName) + assert.is.equal(10, amount) + end) + end) +end) \ No newline at end of file diff --git a/Parser/Parser_spec.lua b/Parser/Parser_spec.lua new file mode 100644 index 0000000..d428611 --- /dev/null +++ b/Parser/Parser_spec.lua @@ -0,0 +1,15 @@ +describe("pre test", function() + it("should be able to load Parser", function() + stub(_G, "L") + stub(_G, "Misc") + stub(_G.Misc, "AddCallback") + stub(_G, "Turbine") + stub(_G.Turbine, "UI") + stub(_G.Turbine.UI, "Control", {parserControl = {}}) + + assert.is.truthy(require('Parser')) + end) + it("should load constants", function() + assert.is.truthy(require('Enums')) + end) +end) \ No newline at end of file