UNPKG

1.44 kBPlain TextView Raw
1import { expect } from 'chai';
2
3import { DI, Injector } from '@leanup/lib';
4
5describe(`Test: Injector-Service (DI)`, () => {
6 const myDI: Injector = new Injector();
7
8 it('DI is instance of Injector', () => {
9 expect(DI instanceof Injector).be.true;
10 expect(myDI instanceof Injector).be.true;
11 });
12
13 describe(`Service registrieren`, () => {
14 function test(type: string, service: any) {
15 it(`Test-Case register (${type})`, () => {
16 // given
17 // when
18 expect(() => {
19 DI.register(type, service);
20 }).not.throw();
21 // then
22 });
23
24 it(`Test-Case get (${type})`, () => {
25 // given
26 // when
27 expect(() => {
28 DI.get(type);
29 }).not.throw();
30 // then
31 });
32 }
33 test(`Array`, []);
34 test(`Object`, {});
35 test(`number`, 0);
36 test(`string`, '');
37 test(`boolean`, true);
38 test(`null`, null);
39 test(`undefined`, undefined);
40 });
41 describe(`Service fehlerhaft registrieren`, () => {
42 function test(type: string, service: any) {
43 it(`Test-Case register (${type})`, () => {
44 // given
45 // when
46 expect(() => {
47 DI.register(type, service);
48 }).throw();
49 // then
50 });
51 }
52 test(`Array`, []);
53 test(`Object`, {});
54 test(`number`, 0);
55 test(`string`, '');
56 test(`boolean`, true);
57 test(`null`, null);
58 test(`undefined`, undefined);
59 });
60});