blessing-skin-server/resources/assets/tests/scripts/cli/RmCommand.test.ts
Zephyr Lykos 9524a234cf
cleanup: wip 3.1
mostly misc cleanups
2024-02-24 23:01:32 +08:00

31 lines
805 B
TypeScript

import {Stdio} from './stdio';
import * as fetch from '@/scripts/net';
import runCommand from '@/scripts/cli/RmCommand';
vi.mock('@/scripts/net');
test('missing operand', async () => {
const stdio = new Stdio();
await runCommand(stdio, []);
expect(stdio.getStdout()).toInclude('missing operand');
expect(fetch.post).not.toBeCalled();
});
test('without "rf"', async () => {
const stdio = new Stdio();
await runCommand(stdio, ['/']);
expect(fetch.post).not.toBeCalled();
});
test('not from root', async () => {
const stdio = new Stdio();
await runCommand(stdio, ['-rf', '.']);
expect(fetch.post).not.toBeCalled();
});
test('send request', async () => {
const stdio = new Stdio();
await runCommand(stdio, ['-rf', '/']);
expect(fetch.post).toBeCalledWith('/admin/resource?clear-cache');
});