Commit f6c88603 authored by nanahira's avatar nanahira

next

parent 8257a154
Pipeline #8554 passed with stages
in 1 minute and 32 seconds
import { App } from 'koishi';
describe('Command next', () => {
let app: App;
beforeEach(() => {
app = new App();
});
it('should response execute command', async () => {
const cmd = app.command('test').action((argv) => 'foo');
expect(await cmd.execute({})).toBe('foo');
});
it('should response execute command with args', async () => {
const cmd = app.command('test').action((argv) => argv.args.join(' '));
expect(await cmd.execute({ args: ['foo', 'bar'] })).toBe('foo bar');
});
it('should response execute command with two actions', async () => {
const cmd = app
.command('test')
.action((argv) => 'foo')
.action((argv) => 'bar');
expect(await cmd.execute({})).toBe('foo');
});
it('should response execute command with two actions and next', async () => {
const cmd = app
.command('test')
.action((argv) => argv.next())
.action((argv) => 'bar');
expect(await cmd.execute({})).toBe('bar');
});
it('should response execute command with two actions and next mutation', async () => {
let ret: void | string;
const cmd = app
.command('test')
.action(async (argv) => {
ret = await argv.next();
return `foo ${ret}`;
})
.action((argv) => 'bar');
expect(await cmd.execute({})).toBe('foo bar');
expect(ret).toBe('bar');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment