ditox 3.2.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +76 -27
  2. package/dist/index.cjs +531 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/{umd/index.d.ts → index.d.cts} +191 -196
  5. package/dist/{browser/index.d.ts → index.d.ts} +191 -196
  6. package/dist/index.js +514 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/index.umd.js +537 -0
  9. package/dist/index.umd.js.map +1 -0
  10. package/package.json +22 -20
  11. package/src/container.test.ts +77 -33
  12. package/src/container.ts +26 -11
  13. package/src/index.ts +22 -24
  14. package/src/modules.test.ts +190 -37
  15. package/src/modules.ts +22 -5
  16. package/src/removal-compatibility.test.ts +259 -0
  17. package/src/removal.test.ts +190 -0
  18. package/src/tokens.test.ts +9 -8
  19. package/src/tokens.ts +2 -2
  20. package/src/utils.test.ts +18 -17
  21. package/src/utils.ts +21 -21
  22. package/dist/browser/index.js +0 -2
  23. package/dist/browser/index.js.map +0 -1
  24. package/dist/cjs/container.d.ts +0 -93
  25. package/dist/cjs/container.js +0 -216
  26. package/dist/cjs/container.js.map +0 -1
  27. package/dist/cjs/index.d.ts +0 -7
  28. package/dist/cjs/index.js +0 -24
  29. package/dist/cjs/index.js.map +0 -1
  30. package/dist/cjs/modules.d.ts +0 -121
  31. package/dist/cjs/modules.js +0 -143
  32. package/dist/cjs/modules.js.map +0 -1
  33. package/dist/cjs/tokens.d.ts +0 -56
  34. package/dist/cjs/tokens.js +0 -20
  35. package/dist/cjs/tokens.js.map +0 -1
  36. package/dist/cjs/utils.d.ts +0 -137
  37. package/dist/cjs/utils.js +0 -156
  38. package/dist/cjs/utils.js.map +0 -1
  39. package/dist/esm/container.d.ts +0 -93
  40. package/dist/esm/container.js +0 -211
  41. package/dist/esm/container.js.map +0 -1
  42. package/dist/esm/index.d.ts +0 -7
  43. package/dist/esm/index.js +0 -5
  44. package/dist/esm/index.js.map +0 -1
  45. package/dist/esm/modules.d.ts +0 -121
  46. package/dist/esm/modules.js +0 -136
  47. package/dist/esm/modules.js.map +0 -1
  48. package/dist/esm/tokens.d.ts +0 -56
  49. package/dist/esm/tokens.js +0 -15
  50. package/dist/esm/tokens.js.map +0 -1
  51. package/dist/esm/utils.d.ts +0 -137
  52. package/dist/esm/utils.js +0 -145
  53. package/dist/esm/utils.js.map +0 -1
  54. package/dist/umd/index.js +0 -2
  55. package/dist/umd/index.js.map +0 -1
@@ -0,0 +1,259 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { bindModule, createContainer, declareModule, token } from './index';
3
+
4
+ describe('3.x removal compatibility', () => {
5
+ it('retains a single binding after its callback throws and allows retry', () => {
6
+ const container = createContainer();
7
+ const resource = token();
8
+ const value = {};
9
+ const failure = new Error('failure');
10
+ const onRemoved = vi.fn().mockImplementationOnce(() => {
11
+ throw failure;
12
+ });
13
+ container.bindFactory(resource, () => value, { onRemoved });
14
+ container.resolve(resource);
15
+
16
+ expect(() => container.remove(resource)).toThrow(failure);
17
+ expect(container.resolve(resource)).toBe(value);
18
+ container.remove(resource);
19
+ expect(container.hasToken(resource)).toBe(false);
20
+ expect(onRemoved).toHaveBeenCalledTimes(2);
21
+ });
22
+
23
+ it('retains a module and its exports after a single removal fails', () => {
24
+ const container = createContainer();
25
+ const exported = token<number>();
26
+ const failure = new Error('destroy failed');
27
+ const destroy = vi.fn().mockImplementationOnce(() => {
28
+ throw failure;
29
+ });
30
+ const module = declareModule({
31
+ factory: () => ({ value: 42, destroy }),
32
+ exports: { value: exported },
33
+ });
34
+ bindModule(container, module);
35
+ expect(container.resolve(exported)).toBe(42);
36
+ expect(() => container.remove(module.token)).toThrow(failure);
37
+ expect(container.hasToken(module.token)).toBe(true);
38
+ expect(container.resolve(exported)).toBe(42);
39
+ container.remove(module.token);
40
+ expect(container.hasToken(module.token)).toBe(false);
41
+ expect(container.hasToken(exported)).toBe(false);
42
+ expect(destroy).toHaveBeenCalledTimes(2);
43
+ });
44
+
45
+ it('keeps legacy removal of replacements made by a single callback', () => {
46
+ const container = createContainer();
47
+ const resource = token();
48
+ const replacementFactory = vi.fn(() => 2);
49
+ container.bindFactory(resource, () => 1, {
50
+ onRemoved() {
51
+ container.bindFactory(resource, replacementFactory);
52
+ container.bindValue(resource, 2);
53
+ },
54
+ });
55
+ container.resolve(resource);
56
+ container.remove(resource);
57
+ expect(container.hasToken(resource)).toBe(false);
58
+ expect(replacementFactory).not.toHaveBeenCalled();
59
+ });
60
+
61
+ it('keeps live traversal when callbacks remove and append other bindings', () => {
62
+ const container = createContainer();
63
+ const first = token();
64
+ const second = token();
65
+ const appended = token();
66
+ const calls: string[] = [];
67
+ container.bindFactory(first, () => 1, {
68
+ onRemoved() {
69
+ calls.push('first');
70
+ container.remove(second);
71
+ container.bindFactory(appended, () => 3, {
72
+ onRemoved: () => {
73
+ calls.push('appended');
74
+ },
75
+ });
76
+ container.resolve(appended);
77
+ },
78
+ });
79
+ container.bindFactory(second, () => 2, {
80
+ onRemoved: () => {
81
+ calls.push('second');
82
+ },
83
+ });
84
+ container.resolve(first);
85
+ container.resolve(second);
86
+ container.removeAll();
87
+ expect(calls).toEqual(['first', 'second', 'appended']);
88
+ [first, second, appended].forEach((resource) =>
89
+ expect(container.hasToken(resource)).toBe(false),
90
+ );
91
+ });
92
+
93
+ it('keeps bounded nested bulk cleanup active rather than making it a no-op', () => {
94
+ const container = createContainer();
95
+ const first = token();
96
+ const second = token();
97
+ const calls: string[] = [];
98
+ let nested = false;
99
+ container.bindFactory(first, () => 1, {
100
+ onRemoved() {
101
+ calls.push('first');
102
+ if (!nested) {
103
+ nested = true;
104
+ container.removeAll();
105
+ expect(container.hasToken(second)).toBe(false);
106
+ calls.push('returned');
107
+ }
108
+ },
109
+ });
110
+ container.bindFactory(second, () => 2, {
111
+ onRemoved: () => {
112
+ calls.push('second');
113
+ },
114
+ });
115
+ container.resolve(first);
116
+ container.resolve(second);
117
+ container.removeAll();
118
+ expect(calls).toEqual(['first', 'first', 'second', 'returned']);
119
+ });
120
+
121
+ it('visits a factory deleted and reinserted at an already visited key', () => {
122
+ const container = createContainer();
123
+ const first = token<number>();
124
+ const second = token();
125
+ const calls: number[] = [];
126
+ const onRemoved = (value: number) => {
127
+ calls.push(value);
128
+ };
129
+ container.bindFactory(first, () => 1, { onRemoved });
130
+ container.bindFactory(second, () => 2, {
131
+ onRemoved() {
132
+ container.remove(first);
133
+ container.bindFactory(first, () => 3, { onRemoved });
134
+ container.resolve(first);
135
+ },
136
+ });
137
+ container.resolve(first);
138
+ container.resolve(second);
139
+ container.removeAll();
140
+ expect(calls).toEqual([1, 1, 3]);
141
+ expect(container.hasToken(first)).toBe(false);
142
+ });
143
+
144
+ it('keeps bounded single-token reentry active', () => {
145
+ const container = createContainer();
146
+ const resource = token();
147
+ let calls = 0;
148
+ container.bindFactory(resource, () => 1, {
149
+ onRemoved() {
150
+ calls++;
151
+ if (calls === 1) container.remove(resource);
152
+ },
153
+ });
154
+ container.resolve(resource);
155
+ container.removeAll();
156
+ expect(calls).toBe(2);
157
+ expect(container.hasToken(resource)).toBe(false);
158
+ });
159
+
160
+ it('does not revisit replacements at already visited keys', () => {
161
+ const container = createContainer();
162
+ const first = token();
163
+ const second = token();
164
+ const onRemoved = vi.fn();
165
+ container.bindFactory(first, () => 1, { onRemoved });
166
+ container.bindFactory(second, () => 2, {
167
+ onRemoved() {
168
+ container.bindValue(first, 3);
169
+ },
170
+ });
171
+ container.resolve(first);
172
+ container.resolve(second);
173
+ container.removeAll();
174
+ expect(onRemoved).toHaveBeenCalledExactlyOnceWith(1);
175
+ expect(container.hasToken(first)).toBe(false);
176
+ });
177
+ });
178
+
179
+ describe('bulk cleanup failures with reentry and accessors', () => {
180
+ it('continues after a nested single removal throws, retaining its legacy retry', () => {
181
+ const container = createContainer();
182
+ const first = token();
183
+ const second = token();
184
+ const last = token();
185
+ const failure = new Error('nested failure');
186
+ const onRemoved = vi.fn(() => {
187
+ throw failure;
188
+ });
189
+ const lastCallback = vi.fn();
190
+ container.bindFactory(first, () => 1, {
191
+ onRemoved: () => container.remove(second),
192
+ });
193
+ container.bindFactory(second, () => 2, { onRemoved });
194
+ container.bindFactory(last, () => 3, { onRemoved: lastCallback });
195
+ [first, second, last].forEach((resource) => container.resolve(resource));
196
+ expect(() => container.removeAll()).toThrow(failure);
197
+ expect(onRemoved).toHaveBeenCalledTimes(2);
198
+ expect(lastCallback).toHaveBeenCalledTimes(1);
199
+ [first, second, last].forEach((resource) =>
200
+ expect(container.hasToken(resource)).toBe(false),
201
+ );
202
+ });
203
+
204
+ it('finishes nested bulk cleanup before propagating its first error', () => {
205
+ const container = createContainer();
206
+ const first = token();
207
+ const second = token();
208
+ const third = token();
209
+ let nested = false;
210
+ const failure = new Error('nested failure');
211
+ const onRemoved = vi.fn();
212
+ container.bindFactory(first, () => 1, {
213
+ onRemoved() {
214
+ if (!nested) {
215
+ nested = true;
216
+ container.removeAll();
217
+ }
218
+ },
219
+ });
220
+ container.bindFactory(second, () => 2, {
221
+ onRemoved() {
222
+ throw failure;
223
+ },
224
+ });
225
+ container.bindFactory(third, () => 3, { onRemoved });
226
+ [first, second, third].forEach((resource) => container.resolve(resource));
227
+ expect(() => container.removeAll()).toThrow(failure);
228
+ expect(onRemoved).toHaveBeenCalledTimes(1);
229
+ [first, second, third].forEach((resource) =>
230
+ expect(container.hasToken(resource)).toBe(false),
231
+ );
232
+ container.removeAll();
233
+ });
234
+
235
+ it('continues after an onRemoved accessor throws even for an unresolved factory', () => {
236
+ const container = createContainer();
237
+ const first = token();
238
+ const second = token();
239
+ const failure = new Error('accessor failed');
240
+ const factory = vi.fn();
241
+ const getter = vi.fn(() => {
242
+ throw failure;
243
+ });
244
+ const onRemoved = vi.fn();
245
+ container.bindFactory(first, factory, {
246
+ get onRemoved() {
247
+ return getter();
248
+ },
249
+ });
250
+ container.bindFactory(second, () => undefined, { onRemoved });
251
+ container.resolve(second);
252
+ expect(() => container.removeAll()).toThrow(failure);
253
+ expect(getter).toHaveBeenCalledTimes(1);
254
+ expect(factory).not.toHaveBeenCalled();
255
+ expect(onRemoved).toHaveBeenCalledExactlyOnceWith(undefined);
256
+ expect(container.hasToken(first)).toBe(false);
257
+ expect(container.hasToken(second)).toBe(false);
258
+ });
259
+ });
@@ -0,0 +1,190 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { bindModule, createContainer, declareModule, token } from './index';
3
+
4
+ describe('container teardown', () => {
5
+ it('finishes cleanup after an onRemoved failure and does not retry callbacks', () => {
6
+ const container = createContainer();
7
+ const failure = new Error('cleanup failed');
8
+ const calls: string[] = [];
9
+ const tokens = ['before', 'failure', 'after'].map((name) => {
10
+ const resource = token(name);
11
+ container.bindFactory(resource, () => ({}), {
12
+ onRemoved() {
13
+ calls.push(name);
14
+ if (name === 'failure') throw failure;
15
+ },
16
+ });
17
+ container.resolve(resource);
18
+ return resource;
19
+ });
20
+ const value = token();
21
+ const unresolved = token();
22
+ const factory = vi.fn();
23
+ const onRemoved = vi.fn();
24
+ container.bindValue(value, 42);
25
+ container.bindFactory(unresolved, factory, { onRemoved });
26
+
27
+ expect(() => container.removeAll()).toThrow(failure);
28
+ expect(calls).toEqual(['before', 'failure', 'after']);
29
+ for (const resource of [...tokens, value, unresolved]) {
30
+ expect(container.hasToken(resource)).toBe(false);
31
+ }
32
+ expect(factory).not.toHaveBeenCalled();
33
+ expect(onRemoved).not.toHaveBeenCalled();
34
+ expect(() => container.removeAll()).not.toThrow();
35
+ expect(calls).toEqual(['before', 'failure', 'after']);
36
+ });
37
+
38
+ it.each([
39
+ new Error('first'),
40
+ undefined,
41
+ null,
42
+ false,
43
+ 0,
44
+ 'failure',
45
+ ])('rethrows the first value unchanged after all callbacks, including %s', (failure) => {
46
+ const container = createContainer();
47
+ const callbacks = [failure, new Error('second')].map((error) => {
48
+ const resource = token();
49
+ const onRemoved = vi.fn(() => {
50
+ throw error;
51
+ });
52
+ container.bindFactory(resource, () => undefined, { onRemoved });
53
+ container.resolve(resource);
54
+ return onRemoved;
55
+ });
56
+ let threw = false;
57
+ try {
58
+ container.removeAll();
59
+ } catch (error) {
60
+ threw = true;
61
+ expect(error).toBe(failure);
62
+ }
63
+ expect(threw).toBe(true);
64
+ callbacks.forEach((callback) => expect(callback).toHaveBeenCalledTimes(1));
65
+ container.removeAll();
66
+ callbacks.forEach((callback) => expect(callback).toHaveBeenCalledTimes(1));
67
+ });
68
+
69
+ it.each([
70
+ 'singleton',
71
+ 'scoped',
72
+ ] as const)('only disposes locally cached %s values and leaves parent values intact', (scope) => {
73
+ const parent = createContainer();
74
+ const child = createContainer(parent);
75
+ const inherited = token();
76
+ const shared = token();
77
+ const owned = token();
78
+ const parentCallback = vi.fn();
79
+ const childCallback = vi.fn(() => {
80
+ throw new Error('child cleanup failed');
81
+ });
82
+ const inheritedFactory = vi.fn(() => ({}));
83
+ const sharedFactory = vi.fn(() => ({}));
84
+ parent.bindFactory(inherited, inheritedFactory, {
85
+ scope,
86
+ onRemoved: parentCallback,
87
+ });
88
+ parent.bindFactory(shared, sharedFactory, {
89
+ scope,
90
+ onRemoved: parentCallback,
91
+ });
92
+ child.bindFactory(shared, sharedFactory, {
93
+ scope,
94
+ onRemoved: childCallback,
95
+ });
96
+ child.bindFactory(owned, () => ({}), { scope, onRemoved: childCallback });
97
+ const inheritedValue = child.resolve(inherited);
98
+ const parentValue = parent.resolve(shared);
99
+ const childValue = child.resolve(shared);
100
+ child.resolve(owned);
101
+
102
+ expect(() => child.removeAll()).toThrow();
103
+ expect(childCallback).toHaveBeenCalledTimes(scope === 'scoped' ? 2 : 1);
104
+ if (scope === 'scoped') {
105
+ expect(childCallback).toHaveBeenCalledWith(childValue);
106
+ expect(childValue).not.toBe(parentValue);
107
+ } else {
108
+ expect(childValue).toBe(parentValue);
109
+ }
110
+ expect(parentCallback).not.toHaveBeenCalled();
111
+ expect(child.resolve(inherited)).toBe(inheritedValue);
112
+ expect(child.resolve(shared)).toBe(parentValue);
113
+ child.removeAll();
114
+ parent.removeAll();
115
+ expect(parentCallback).toHaveBeenCalledTimes(2);
116
+ expect(inheritedFactory).toHaveBeenCalledTimes(1);
117
+ expect(sharedFactory).toHaveBeenCalledTimes(scope === 'scoped' ? 2 : 1);
118
+ });
119
+
120
+ it('keeps resolved dependencies available during normal bulk callbacks', () => {
121
+ const container = createContainer();
122
+ const dependency = token();
123
+ const consumer = token();
124
+ const value = {};
125
+ const onRemoved = vi.fn();
126
+ container.bindFactory(dependency, () => value, { onRemoved });
127
+ container.bindFactory(consumer, () => ({}), {
128
+ onRemoved() {
129
+ expect(container.resolve(dependency)).toBe(value);
130
+ },
131
+ });
132
+ container.resolve(dependency);
133
+ container.resolve(consumer);
134
+ container.removeAll();
135
+ expect(onRemoved).toHaveBeenCalledTimes(1);
136
+ });
137
+
138
+ it('does not resolve unused factories or dispose transient values', () => {
139
+ const container = createContainer();
140
+ const unused = token();
141
+ const transient = token();
142
+ const unusedFactory = vi.fn();
143
+ const unusedCallback = vi.fn();
144
+ const transientFactory = vi.fn(() => ({}));
145
+ const transientCallback = vi.fn();
146
+ container.bindFactory(unused, unusedFactory, { onRemoved: unusedCallback });
147
+ // JavaScript callers can pass extra options; transient still has no teardown.
148
+ const options = {
149
+ scope: 'transient' as const,
150
+ onRemoved: transientCallback,
151
+ };
152
+ container.bindFactory(transient, transientFactory, options);
153
+ expect(container.resolve(transient)).not.toBe(container.resolve(transient));
154
+
155
+ container.removeAll();
156
+ expect(unusedFactory).not.toHaveBeenCalled();
157
+ expect(unusedCallback).not.toHaveBeenCalled();
158
+ expect(transientFactory).toHaveBeenCalledTimes(2);
159
+ expect(transientCallback).not.toHaveBeenCalled();
160
+ expect(container.hasToken(transient)).toBe(false);
161
+ });
162
+
163
+ it('cleans module exports and subsequent modules after destroy throws', () => {
164
+ const container = createContainer();
165
+ const exported = token<number>();
166
+ const failure = new Error('module cleanup failed');
167
+ const failingModule = declareModule({
168
+ factory: () => ({
169
+ value: 42,
170
+ destroy: () => {
171
+ throw failure;
172
+ },
173
+ }),
174
+ exports: { value: exported },
175
+ });
176
+ const destroy = vi.fn();
177
+ const healthyModule = declareModule({ factory: () => ({ destroy }) });
178
+ bindModule(container, failingModule);
179
+ bindModule(container, healthyModule);
180
+ expect(container.resolve(exported)).toBe(42);
181
+ container.resolve(healthyModule.token);
182
+
183
+ expect(() => container.removeAll()).toThrow(failure);
184
+ expect(container.hasToken(exported)).toBe(false);
185
+ expect(container.hasToken(failingModule.token)).toBe(false);
186
+ expect(container.hasToken(healthyModule.token)).toBe(false);
187
+ container.removeAll();
188
+ expect(destroy).toHaveBeenCalledTimes(1);
189
+ });
190
+ });
@@ -1,10 +1,11 @@
1
- import {optional, token} from './tokens';
1
+ import { describe, expect, it } from 'vitest';
2
+ import { optional, token } from './tokens';
2
3
 
3
4
  describe('token()', () => {
4
5
  it('should return a token with description it is specified', () => {
5
6
  expect(token().symbol.description).toBeUndefined();
6
7
  expect(token('text1').symbol.description).toBe('text1');
7
- expect(token({description: 'text2'}).symbol.description).toBe('text2');
8
+ expect(token({ description: 'text2' }).symbol.description).toBe('text2');
8
9
  });
9
10
 
10
11
  it('should return independent tokens if key is not specified', () => {
@@ -17,9 +18,9 @@ describe('token()', () => {
17
18
  });
18
19
 
19
20
  it('should return tokens with the same symbol if key is specified', () => {
20
- const source = token({key: 'test-token'});
21
- const clone = token({key: 'test-token'});
22
- const something = token({key: 'something-else'});
21
+ const source = token({ key: 'test-token' });
22
+ const clone = token({ key: 'test-token' });
23
+ const something = token({ key: 'something-else' });
23
24
 
24
25
  expect(source).not.toBe(clone);
25
26
  expect(source.symbol).toBe(clone.symbol);
@@ -44,9 +45,9 @@ describe('optional()', () => {
44
45
  expect(o2.optionalValue).toBe(-1);
45
46
  });
46
47
 
47
- it('should reuse symbol from a source token ifits key is specified', () => {
48
- const source = token({key: 'token-key'});
49
- const clone = token({key: 'token-key'});
48
+ it('should reuse symbol from a source token if its key is specified', () => {
49
+ const source = token({ key: 'token-key' });
50
+ const clone = token({ key: 'token-key' });
50
51
  const optClone = optional(clone);
51
52
 
52
53
  expect(optClone.symbol).toBe(source.symbol);
package/src/tokens.ts CHANGED
@@ -56,13 +56,13 @@ export function token<T>(description?: string): Token<T>;
56
56
  */ export function token<T>(options?: TokenOptions): Token<T>;
57
57
  export function token<T>(options?: TokenOptions | string): Token<T> {
58
58
  const normalized: TokenOptions | undefined =
59
- typeof options === 'string' ? {description: options} : options;
59
+ typeof options === 'string' ? { description: options } : options;
60
60
 
61
61
  const symbol: symbol = normalized?.key
62
62
  ? Symbol.for(normalized.key)
63
63
  : Symbol(normalized?.description);
64
64
 
65
- return {symbol};
65
+ return { symbol };
66
66
  }
67
67
 
68
68
  /**
package/src/utils.test.ts CHANGED
@@ -1,4 +1,6 @@
1
- import {createContainer, ResolverError} from './container';
1
+ import { describe, expect, it } from 'vitest';
2
+ import { createContainer, ResolverError } from './container';
3
+ import { optional, token } from './tokens';
2
4
  import {
3
5
  bindMultiValue,
4
6
  injectable,
@@ -8,7 +10,6 @@ import {
8
10
  tryResolveValue,
9
11
  tryResolveValues,
10
12
  } from './utils';
11
- import {optional, token} from './tokens';
12
13
 
13
14
  const NUMBER = token<number>('number');
14
15
  const STRING = token<string>('string');
@@ -60,19 +61,19 @@ describe('tryResolveValue()', () => {
60
61
  container.bindValue(NUMBER, 1);
61
62
  container.bindValue(STRING, 'abc');
62
63
 
63
- const props: {a: number; b: string} = tryResolveValue(container, {
64
+ const props: { a: number; b: string } = tryResolveValue(container, {
64
65
  a: NUMBER,
65
66
  b: STRING,
66
67
  });
67
- expect(props).toEqual({a: 1, b: 'abc'});
68
+ expect(props).toEqual({ a: 1, b: 'abc' });
68
69
  });
69
70
 
70
71
  it('should return "undefined" item in case a value is not provided', () => {
71
72
  const container = createContainer();
72
73
  container.bindValue(NUMBER, 1);
73
74
 
74
- const props = tryResolveValue(container, {a: NUMBER, b: STRING});
75
- expect(props).toEqual({a: 1, b: undefined});
75
+ const props = tryResolveValue(container, { a: NUMBER, b: STRING });
76
+ expect(props).toEqual({ a: 1, b: undefined });
76
77
  });
77
78
 
78
79
  it('should return values of optional tokens in case they are not provided', () => {
@@ -86,7 +87,7 @@ describe('tryResolveValue()', () => {
86
87
  b: STRING,
87
88
  c: OPTIONAL_STRING,
88
89
  });
89
- expect(props).toEqual({a: 1, b: undefined, c: 'value'});
90
+ expect(props).toEqual({ a: 1, b: undefined, c: 'value' });
90
91
  });
91
92
  });
92
93
 
@@ -149,11 +150,11 @@ describe('resolveValue()', () => {
149
150
  container.bindValue(NUMBER, 1);
150
151
  container.bindValue(STRING, 'abc');
151
152
 
152
- const props: {a: number; b: string} = resolveValue(container, {
153
+ const props: { a: number; b: string } = resolveValue(container, {
153
154
  a: NUMBER,
154
155
  b: STRING,
155
156
  });
156
- expect(props).toEqual({a: 1, b: 'abc'});
157
+ expect(props).toEqual({ a: 1, b: 'abc' });
157
158
  });
158
159
 
159
160
  it('should throw an error in case a value is not provided', () => {
@@ -161,7 +162,7 @@ describe('resolveValue()', () => {
161
162
  container.bindValue(NUMBER, 1);
162
163
 
163
164
  expect(() => {
164
- resolveValue(container, {a: NUMBER, b: STRING});
165
+ resolveValue(container, { a: NUMBER, b: STRING });
165
166
  }).toThrowError(
166
167
  new ResolverError(`Token "${STRING.symbol.description}" is not provided`),
167
168
  );
@@ -175,7 +176,7 @@ describe('resolveValue()', () => {
175
176
  a: NUMBER,
176
177
  b: optional(STRING, 'value'),
177
178
  });
178
- expect(props).toEqual({a: 1, b: 'value'});
179
+ expect(props).toEqual({ a: 1, b: 'value' });
179
180
  });
180
181
  });
181
182
 
@@ -224,7 +225,7 @@ describe('resolveValues()', () => {
224
225
  });
225
226
 
226
227
  describe('injectable()', () => {
227
- function join({a, b}: {a: number; b: string}): string {
228
+ function join({ a, b }: { a: number; b: string }): string {
228
229
  return `${a}/${b}`;
229
230
  }
230
231
 
@@ -275,7 +276,7 @@ describe('injectable()', () => {
275
276
  container.bindValue(NUMBER, 1);
276
277
  container.bindValue(STRING, '2');
277
278
 
278
- const decoratedFactory = injectable(join, {a: NUMBER, b: STRING});
279
+ const decoratedFactory = injectable(join, { a: NUMBER, b: STRING });
279
280
 
280
281
  expect(decoratedFactory(container)).toBe('1/2');
281
282
  });
@@ -284,7 +285,7 @@ describe('injectable()', () => {
284
285
  const container = createContainer();
285
286
  container.bindValue(NUMBER, 1);
286
287
 
287
- const decoratedFactory = injectable(join, {a: NUMBER, b: STRING});
288
+ const decoratedFactory = injectable(join, { a: NUMBER, b: STRING });
288
289
 
289
290
  expect(() => decoratedFactory(container)).toThrowError(
290
291
  new ResolverError(`Token "${STRING.symbol.description}" is not provided`),
@@ -359,7 +360,7 @@ describe('injectableClass()', () => {
359
360
  a: number;
360
361
  b: string;
361
362
 
362
- constructor(props: {a: number; b: string}) {
363
+ constructor(props: { a: number; b: string }) {
363
364
  this.a = props.a;
364
365
  this.b = props.b;
365
366
  }
@@ -374,7 +375,7 @@ describe('injectableClass()', () => {
374
375
  container.bindValue(NUMBER, 1);
375
376
  container.bindValue(STRING, '2');
376
377
 
377
- const factory = injectableClass(TestClass, {a: NUMBER, b: STRING});
378
+ const factory = injectableClass(TestClass, { a: NUMBER, b: STRING });
378
379
 
379
380
  expect(factory(container).join()).toBe('1/2');
380
381
  });
@@ -383,7 +384,7 @@ describe('injectableClass()', () => {
383
384
  const container = createContainer();
384
385
  container.bindValue(NUMBER, 1);
385
386
 
386
- const factory = injectableClass(TestClass, {a: NUMBER, b: STRING});
387
+ const factory = injectableClass(TestClass, { a: NUMBER, b: STRING });
387
388
 
388
389
  expect(() => factory(container)).toThrowError(
389
390
  new ResolverError(`Token "${STRING.symbol.description}" is not provided`),