mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
7382a3541f
feat(slock): add collaboration adapter Co-authored-by: codex-mini1 <codex-mini1@users.noreply.github.com> Co-authored-by: First-principles-1 <first-principles-1@users.noreply.github.com>
30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { ArgumentError, AuthRequiredError, CommandExecutionError, ConfigError } from '@jackwener/opencli/errors';
|
|
import { dispatchEvaluateResult } from './errors.js';
|
|
|
|
describe('dispatchEvaluateResult', () => {
|
|
it('returns rows on kind:"ok"', () => {
|
|
const rows = dispatchEvaluateResult({ kind: 'ok', rows: [{ a: 1 }] });
|
|
expect(rows).toEqual([{ a: 1 }]);
|
|
});
|
|
|
|
it('throws AuthRequiredError on kind:"auth"', () => {
|
|
expect(() => dispatchEvaluateResult({ kind: 'auth', detail: 'x' })).toThrow(AuthRequiredError);
|
|
});
|
|
|
|
it('throws CommandExecutionError on kind:"http" with status + where', () => {
|
|
expect(() => dispatchEvaluateResult({ kind: 'http', status: 500, where: '/messages' }))
|
|
.toThrow(/HTTP 500.*\/messages/);
|
|
});
|
|
|
|
it('throws ConfigError on kind:"no-server"', () => {
|
|
expect(() => dispatchEvaluateResult({ kind: 'no-server', detail: 'no slug' }))
|
|
.toThrow(ConfigError);
|
|
});
|
|
|
|
it('throws ArgumentError on kind:"unresolvable"', () => {
|
|
expect(() => dispatchEvaluateResult({ kind: 'unresolvable', detail: 'short id had 0 matches' }))
|
|
.toThrow(ArgumentError);
|
|
});
|
|
});
|