DeepCodeGeniusWeb-vscode/test/action/customAction.test.ts
bobo.yang d99548b3a0 Add unit tests for actions with valid and empty args
- Add a test case for applying an action with valid args.
- Add a test case for applying an action with empty args.
2023-07-24 00:11:56 +08:00

30 lines
914 B
TypeScript

import { expect } from 'chai';
import 'mocha';
import { CustomActions } from '../../src/action/customAction';
describe('CustomActions', () => {
const customActions = CustomActions.getInstance();
it('should return an empty action list', () => {
const actions = customActions.getActions();
expect(actions).to.deep.equal([]);
});
it('should return a non-empty action instruction with actions', () => {
// Add a sample action to the customActions instance
customActions.getActions().push({
name: 'sampleAction',
description: 'A sample action for testing',
type: ['test'],
action: 'sample',
handler: [],
args: [],
handlerAction: async (args: { [key: string]: string }) => {
return { exitCode: 0, stdout: '', stderr: '' };
},
});
const instruction = customActions.actionInstruction();
expect(instruction).to.include('sampleAction: A sample action for testing');
});
});