1 | import { expect } from 'chai';
|
2 |
|
3 | import { DI, Injector } from '@leanup/lib';
|
4 |
|
5 | describe(`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 |
|
17 |
|
18 | expect(() => {
|
19 | DI.register(type, service);
|
20 | }).not.throw();
|
21 |
|
22 | });
|
23 |
|
24 | it(`Test-Case get (${type})`, () => {
|
25 |
|
26 |
|
27 | expect(() => {
|
28 | DI.get(type);
|
29 | }).not.throw();
|
30 |
|
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 |
|
45 |
|
46 | expect(() => {
|
47 | DI.register(type, service);
|
48 | }).throw();
|
49 |
|
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 | });
|