9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
import { describe, it, expect, vi } from 'vitest';
|
|
import { ArgumentError } from '@jackwener/opencli/errors';
|
|
import { getRegistry } from '@jackwener/opencli/registry';
|
|
import './channel-create.js';
|
|
|
|
function makePage(result = { kind: 'ok', rows: { id: 'c1', name: 'launch', type: 'channel' } }) {
|
|
return { goto: vi.fn(), evaluate: vi.fn().mockResolvedValue(result) };
|
|
}
|
|
|
|
describe('slock channel-create', () => {
|
|
const command = getRegistry().get('slock/channel-create');
|
|
|
|
it('empty name rejected before navigation', async () => {
|
|
const page = makePage();
|
|
await expect(command.func(page, { name: ' ' })).rejects.toBeInstanceOf(ArgumentError);
|
|
expect(page.goto).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('defaults to public visibility', async () => {
|
|
const page = makePage();
|
|
const rows = await command.func(page, { name: 'launch' });
|
|
expect(page.evaluate.mock.calls[0][0]).toContain('public');
|
|
expect(rows[0]).toMatchObject({ id: 'c1', name: 'launch', result: 'created' });
|
|
});
|
|
|
|
it('--private sends visibility:private', async () => {
|
|
const page = makePage();
|
|
await command.func(page, { name: 'secret', private: true });
|
|
const script = page.evaluate.mock.calls[0][0];
|
|
expect(script).toContain('visibility');
|
|
expect(script).toContain('private');
|
|
});
|
|
|
|
it('over-long --description is rejected', async () => {
|
|
const page = makePage();
|
|
await expect(command.func(page, { name: 'x', description: 'a'.repeat(501) }))
|
|
.rejects.toBeInstanceOf(ArgumentError);
|
|
expect(page.goto).not.toHaveBeenCalled();
|
|
});
|
|
});
|