local t = require('spec.zync_test')
local Commands = require('zync.api.commands.commands')
local parser_stub = require('spec.stubs.parser_stub')
local assert = t.assert
describe('Commands builder', function()
before_each(function()
t.helpers.setup()
parser_stub.load()
end)
after_each(function()
parser_stub.revert()
t.helpers.teardown()
end)
it('builds the command table with shorthands and args', function()
local commands = Commands.build(parser_stub)
local keys = {
'init',
'conf',
'build',
'flash',
'run',
'clean',
'boards',
'runners',
'profiles',
}
for _, key in ipairs(keys) do
assert.is_table(commands[key])
end
assert.equal('build', commands.build.name)
assert.equal('flash', commands.flash.name)
assert.equal('run', commands.run.name)
assert.is_true(t.helpers.table_contains(commands.build.args, 'board'))
assert.is_true(t.helpers.table_contains(commands.build.args, 'runner'))
assert.is_true(t.helpers.table_contains(commands.flash.args, 'image'))
assert.is_true(t.helpers.table_contains(commands.flash.args, 'list'))
assert.is_true(t.helpers.table_contains(commands.run.args, 'image'))
assert.is_true(t.helpers.table_contains(commands.run.args, 'list'))
end)
end)