Skip to content

Commit 3e08920

Browse files
committed
fix(tests): cover keyword entity, duplicate service registration
1 parent 3043b17 commit 3e08920

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

test/entity/misc/TestKeyword.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { expect } from 'chai';
2+
3+
import { CommandVerb } from '../../../src/entity/Command';
4+
import { Keyword } from '../../../src/entity/misc/Keyword';
5+
import { describeLeaks, itLeaks } from '../../helpers/async';
6+
7+
describeLeaks('keyword entity', async () => {
8+
itLeaks('should convert itself to JSON', async () => {
9+
const keyword = new Keyword({
10+
controllerId: '',
11+
data: {},
12+
key: '',
13+
labels: {},
14+
noun: 'test',
15+
verb: CommandVerb.Create,
16+
});
17+
const json = keyword.toJSON();
18+
expect(json).to.have.property('noun');
19+
expect(json).to.have.property('verb');
20+
});
21+
});

test/migration/TestMigrations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ describeLeaks('database migrations', async () => {
3333
},
3434
});
3535
await storage.start();
36+
await storage.stop();
3637
});
3738

3839
itLeaks('should run down');

test/module/TestServiceModule.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { expect } from 'chai';
22
import { ineeda } from 'ineeda';
3+
import { Logger } from 'noicejs';
34
import { spy } from 'sinon';
45

56
import { ServiceModule } from '../../src/module/ServiceModule';
67
import { Service, ServiceEvent } from '../../src/Service';
78
import { defer } from '../../src/utils/Async';
89
import { describeLeaks, itLeaks } from '../helpers/async';
9-
import { createContainer } from '../helpers/container';
10+
import { createContainer, createServiceContainer } from '../helpers/container';
1011

1112
const TEST_SERVICE_NAME = 'test-service';
1213

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

79-
itLeaks('should warn when adding duplicate services');
80+
itLeaks('should warn when adding duplicate services', async () => {
81+
const { services } = await createServiceContainer();
82+
83+
const warn = spy();
84+
services.logger = ineeda<Logger>({
85+
warn,
86+
});
87+
88+
const svc = ineeda<Service>({
89+
kind: 'test',
90+
name: 'service',
91+
});
92+
services.addService(svc);
93+
services.addService(svc);
94+
95+
expect(warn).to.have.callCount(1);
96+
});
8097
});
8198
});

0 commit comments

Comments
 (0)