fix faiklling test

This commit is contained in:
Jacob Nguyen
2024-05-20 19:36:36 -05:00
parent e0f6a4cd16
commit e700297bfc
10 changed files with 149 additions and 243 deletions

View File

@@ -2,17 +2,12 @@ import { describe, it, expect } from 'vitest';
import {
CommandControlPlugin,
CommandInitPlugin,
EventControlPlugin,
EventInitPlugin,
} from '../../src/core/create-plugins';
import { PluginType, controller } from '../../src';
describe('create-plugins', () => {
it('should make proper control plugins', () => {
const pl = EventControlPlugin(() => controller.next());
expect(pl).to.have.all.keys(['type', 'execute']);
expect(pl.type).toBe(PluginType.Control);
expect(pl.execute).an('function');
const pl2 = CommandControlPlugin(() => controller.next());
expect(pl2).to.have.all.keys(['type', 'execute']);
expect(pl2.type).toBe(PluginType.Control);

View File

@@ -1,7 +1,6 @@
import { beforeEach, describe, expect, vi, it } from 'vitest';
import { eventDispatcher } from '../../src/handlers/event-utils';
import { faker } from '@faker-js/faker';
import { TestScheduler } from 'rxjs/testing';
import { Module } from '../../src/types/core-modules';
import { Processed } from '../../src/types/core-modules';
import { EventEmitter } from 'events';
@@ -19,12 +18,13 @@ function createRandomModule(): Processed<Module> {
};
}
const testScheduler = new TestScheduler((actual, expected) => {
// asserting the two objects are equal - required
// for TestScheduler assertions to work via your test framework
// e.g. using chai.
expect(actual).deep.equal(expected);
});
function mockDeps() {
return {
'@sern/client': {}
}
}
describe('eventDispatcher standard', () => {
let m: Processed<Module>;
@@ -35,19 +35,10 @@ describe('eventDispatcher standard', () => {
});
it('should throw', () => {
expect(() => eventDispatcher(m, 'not event emitter')).toThrowError();
expect(() => eventDispatcher(mockDeps(), m, 'not event emitter')).toThrowError();
});
it("Shouldn't throw", () => {
expect(() => eventDispatcher(m, ee)).not.toThrowError();
expect(() => eventDispatcher(mockDeps(), m, ee)).not.toThrowError();
});
//TODO
// it('Should be called once', () => {
// const s = eventDispatcher(m, ee);
// console.log(m)
// s.subscribe();
// ee.emit(m.name);
// console.log(m.execute)
// expect(m.execute).toHaveBeenCalledOnce();
// });
});