Skip to content

Commit

Permalink
Back: Fix plugin.stop test
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuAndrade committed Oct 14, 2023
1 parent 7e2d021 commit 986b87a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion apps/server/test/core/plugin/plugin.stop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import wait from '../../utils/timer';
let plugin: Plugin;
let container: Container;

const listenerArgs = {
type: 'plugin.stopped',
message: { id: '33ddf1e2-3c51-4426-93af-3b0453ac0c1e' },
};

describe('Plugin.stop', () => {
before(async () => {
plugin = global.FRIDAY.plugin;
Expand Down Expand Up @@ -52,7 +57,7 @@ describe('Plugin.stop', () => {
await wait(80);
expect(result).equal(true);
expect(listener.called).equal(true);
expect(listener.args[0][0].type).to.equal(AvailableState.PLUGIN_STOPPED);
expect(listener.calledWith(listenerArgs)).to.equal(true);
});

it('should not stop a plugin already stopped', async function stop() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AvailableState, EventsType } from '@friday-ai/shared';
import { EventsType } from '@friday-ai/shared';
import { assert, expect } from 'chai';
import { Container } from 'dockerode';
import sinon from 'sinon';
Expand All @@ -8,6 +8,11 @@ import { NotFoundError } from '../../../src/utils/decorators/error';
let satellite: Satellite;
let container: Container;

const listenerArgs = {
type: 'plugin.stopped',
message: { id: '88b48273-15e6-4729-9199-0682677475f4' },
};

describe('Satellite.stopAllPlugins', () => {
before(async () => {
satellite = global.FRIDAY.satellite;
Expand Down Expand Up @@ -49,7 +54,7 @@ describe('Satellite.stopAllPlugins', () => {

await assert.isFulfilled(promise);
expect(listener.called).equal(true);
expect(listener.args[0][0].type).to.equal(AvailableState.PLUGIN_STOPPED);
expect(listener.calledWith(listenerArgs)).to.equal(true);
});

it('should not found satellite', async () => {
Expand Down

0 comments on commit 986b87a

Please sign in to comment.