|
| 1 | +describe("StatDescriber getScope scenarios", function() |
| 2 | + before_each(function() |
| 3 | + newBuild() |
| 4 | + end) |
| 5 | + |
| 6 | + teardown(function() |
| 7 | + -- newBuild() resets environment in setup() |
| 8 | + end) |
| 9 | + |
| 10 | + local cases = { |
| 11 | + { name = "should_load_lowercase_prefixed_herald_scope", scope = "specific_skill_stat_descriptions/herald_of_thunder_statset_1", stats = {}, shouldSucceed = true, expectedOutputLines = 0 }, |
| 12 | + { name = "should_load_herald_scope_without_prefix", scope = "herald_of_thunder_statset_1", stats = {}, shouldSucceed = true, expectedOutputLines = 0 }, |
| 13 | + { name = "should_load_alchemist_boon_scope", scope = "alchemist_boon", stats = {}, shouldSucceed = true, expectedOutputLines = 0 }, |
| 14 | + { name = "should_load_skill_stat_descriptions", scope = "skill_stat_descriptions", stats = {}, shouldSucceed = true, expectedOutputLines = 0 }, |
| 15 | + { name = "should_generate_output_for_life_stat", scope = "stat_descriptions", stats = { base_maximum_life = 50 }, shouldSucceed = true, expectedOutputLines = 1 }, |
| 16 | + { name = "should_generate_output_for_alchemist_boon_flask_recovery", scope = "alchemist_boon", stats = { ["recovery_from_flasks_applies_to_allies_in_presence_%"] = 30 }, shouldSucceed = true, expectedOutputLines = 1 }, |
| 17 | + { name = "should_generate_output_for_fireball_area_radius", scope = "fireball", stats = { active_skill_base_area_of_effect_radius = 15 }, shouldSucceed = true, expectedOutputLines = 1 }, |
| 18 | + { name = "should_fail_for_nonexistent_scope", scope = "definitely_nonexistent_scope_12345", stats = {}, shouldSucceed = false }, |
| 19 | + { name = "should_fail_for_nonexistent_prefixed_scope", scope = "specific_skill_stat_descriptions/definitely_nonexistent_scope_12345", stats = {}, shouldSucceed = false }, |
| 20 | + } |
| 21 | + |
| 22 | + for _, case in ipairs(cases) do |
| 23 | + it(case.name, function() |
| 24 | + ConPrintf("[StatDescriber getScope] %s", case.name) |
| 25 | + local describe = require("Modules/StatDescriber") |
| 26 | + |
| 27 | + if case.shouldSucceed then |
| 28 | + local out, lineMap = describe(case.stats, case.scope) |
| 29 | + assert.are.equal("table", type(out)) |
| 30 | + assert.are.equal("table", type(lineMap)) |
| 31 | + if case.expectedOutputLines then |
| 32 | + assert.are.equal(case.expectedOutputLines, #out) |
| 33 | + end |
| 34 | + else |
| 35 | + local ok, err = pcall(function() |
| 36 | + describe(case.stats, case.scope) |
| 37 | + end) |
| 38 | + assert.False(ok) |
| 39 | + assert.is_string(err) |
| 40 | + end |
| 41 | + end) |
| 42 | + end |
| 43 | +end) |
0 commit comments