Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tier): Add isValidTierType #4358

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions spec/tier_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ describe('tier', function()
end)
end)

describe('is valid tiertype', function()
it('check', function()
assert.is_true(Tier.isValidTierType('showmatch'))
assert.is_true(Tier.isValidTierType('show match'))
assert.is_true(Tier.isValidTierType('qualifier'))
assert.is_true(Tier.isValidTierType(''))
assert.is_true(Tier.isValidTierType())
Comment on lines +45 to +46
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert.is_true(Tier.isValidTierType(''))
assert.is_true(Tier.isValidTierType())
assert.is_false(Tier.isValidTierType(''))
assert.is_false(Tier.isValidTierType())

assert.is_false(Tier.isValidTierType('foo'))
end)
end)

describe('to value', function()
it('check', function()
assert.are_same({'1', 'Showmatch'}, {Tier.toValue(1, 'show match')})
Expand Down
12 changes: 11 additions & 1 deletion standard/tier/commons/tier_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Tier.toIdentifier(input)
end

--- Retrieves the raw data for a given (tier, tierType) tuple
---@param tier integer
---@param tier string|integer?
---@param tierType string?
---@return table?, table?
function Tier.raw(tier, tierType)
Expand All @@ -60,6 +60,16 @@ function Tier.isValid(tier, tierType)
return true
end

--- Checks if a valid tierType is provided
---@param tierType string?
---@return boolean
function Tier.isValidTierType(tierType)
if String.isEmpty(tierType) then return true end

Comment on lines +67 to +68
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if String.isEmpty(tierType) then return true end

local _, tierTypeData = Tier.raw(nil, tierType)
return tierTypeData ~= nil
end

--- Converts input to (storage) values for a given (tier, tierType) tuple
---@param tier integer
---@param tierType string?
Expand Down
Loading