Skip to content

Commit

Permalink
fix(tests): cover keyword entity, duplicate service registration
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Oct 26, 2019
1 parent 3043b17 commit 3e08920
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
21 changes: 21 additions & 0 deletions test/entity/misc/TestKeyword.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect } from 'chai';

import { CommandVerb } from '../../../src/entity/Command';
import { Keyword } from '../../../src/entity/misc/Keyword';
import { describeLeaks, itLeaks } from '../../helpers/async';

describeLeaks('keyword entity', async () => {
itLeaks('should convert itself to JSON', async () => {
const keyword = new Keyword({
controllerId: '',
data: {},
key: '',
labels: {},
noun: 'test',
verb: CommandVerb.Create,
});
const json = keyword.toJSON();
expect(json).to.have.property('noun');
expect(json).to.have.property('verb');
});
});
1 change: 1 addition & 0 deletions test/migration/TestMigrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describeLeaks('database migrations', async () => {
},
});
await storage.start();
await storage.stop();
});

itLeaks('should run down');
Expand Down
21 changes: 19 additions & 2 deletions test/module/TestServiceModule.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { expect } from 'chai';
import { ineeda } from 'ineeda';
import { Logger } from 'noicejs';
import { spy } from 'sinon';

import { ServiceModule } from '../../src/module/ServiceModule';
import { Service, ServiceEvent } from '../../src/Service';
import { defer } from '../../src/utils/Async';
import { describeLeaks, itLeaks } from '../helpers/async';
import { createContainer } from '../helpers/container';
import { createContainer, createServiceContainer } from '../helpers/container';

const TEST_SERVICE_NAME = 'test-service';

Expand Down Expand Up @@ -76,6 +77,22 @@ describeLeaks('DI modules', async () => {
expect(existing.has(tag)).to.equal(true);
});

itLeaks('should warn when adding duplicate services');
itLeaks('should warn when adding duplicate services', async () => {
const { services } = await createServiceContainer();

const warn = spy();
services.logger = ineeda<Logger>({
warn,
});

const svc = ineeda<Service>({
kind: 'test',
name: 'service',
});
services.addService(svc);
services.addService(svc);

expect(warn).to.have.callCount(1);
});
});
});

0 comments on commit 3e08920

Please sign in to comment.