@servicetitan/react-ioc 28.1.1 → 28.3.0
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.
- package/dist/__tests__/await.test.d.ts +2 -0
- package/dist/__tests__/await.test.d.ts.map +1 -0
- package/dist/__tests__/await.test.js +16 -0
- package/dist/__tests__/await.test.js.map +1 -0
- package/dist/__tests__/provide.test.d.ts +2 -0
- package/dist/__tests__/provide.test.d.ts.map +1 -0
- package/dist/__tests__/provide.test.js +62 -0
- package/dist/__tests__/provide.test.js.map +1 -0
- package/dist/__tests__/provider.test.d.ts +2 -0
- package/dist/__tests__/provider.test.d.ts.map +1 -0
- package/dist/__tests__/provider.test.js +277 -0
- package/dist/__tests__/provider.test.js.map +1 -0
- package/dist/__tests__/react-ioc.test.d.ts +2 -0
- package/dist/__tests__/react-ioc.test.d.ts.map +1 -0
- package/dist/__tests__/react-ioc.test.js +227 -0
- package/dist/__tests__/react-ioc.test.js.map +1 -0
- package/dist/use-dependencies.js +1 -1
- package/dist/use-dependencies.js.map +1 -1
- package/package.json +4 -4
- package/src/use-dependencies.ts +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"await.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/await.test.tsx"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, waitFor } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { Await } from '../await';
|
|
5
|
+
describe('[react-ioc] Await', () => {
|
|
6
|
+
const testContent = 'hello';
|
|
7
|
+
const TestContent = () => _jsx("div", { role: "content", children: testContent });
|
|
8
|
+
const subject = () => render(_jsx(Await, { promises: [], children: _jsx(TestContent, {}) }));
|
|
9
|
+
test('renders content', async () => {
|
|
10
|
+
const { container } = subject();
|
|
11
|
+
await waitFor(() => {
|
|
12
|
+
expect(container).toHaveTextContent(testContent);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=await.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"await.test.js","sourceRoot":"","sources":["../../src/__tests__/await.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,2BAA2B,CAAC;AAEnC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC/B,MAAM,WAAW,GAAG,OAAO,CAAC;IAE5B,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,cAAK,IAAI,EAAC,SAAS,YAAE,WAAW,GAAO,CAAC;IAElE,MAAM,OAAO,GAAG,GAAG,EAAE,CACjB,MAAM,CACF,KAAC,KAAK,IAAC,QAAQ,EAAE,EAAE,YACf,KAAC,WAAW,KAAG,GACX,CACX,CAAC;IAEN,IAAI,CAAC,iBAAiB,EAAE,KAAK,IAAI,EAAE;QAC/B,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC;QAEhC,MAAM,OAAO,CAAC,GAAG,EAAE;YACf,MAAM,CAAC,SAAS,CAAC,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provide.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/provide.test.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { Fragment } from 'react';
|
|
5
|
+
import { provide } from '../provide';
|
|
6
|
+
jest.mock('../provider', () => ({
|
|
7
|
+
Provider: ({ children, ...props }) => {
|
|
8
|
+
return (_jsxs(Fragment, { children: [`<Provider ${JSON.stringify(props)} />`, children] }));
|
|
9
|
+
},
|
|
10
|
+
}));
|
|
11
|
+
describe('[react-ioc] provide', () => {
|
|
12
|
+
let stores;
|
|
13
|
+
let options;
|
|
14
|
+
let props;
|
|
15
|
+
const subject = () => {
|
|
16
|
+
const Component = provide(stores, options)(renderProps => _jsx("div", { children: `<Component ${JSON.stringify(renderProps)} />` }));
|
|
17
|
+
return render(_jsx(Component, { ...props }));
|
|
18
|
+
};
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
stores = { singletons: [], instances: [] };
|
|
21
|
+
options = undefined;
|
|
22
|
+
props = { foo: 'bar' };
|
|
23
|
+
});
|
|
24
|
+
test('renders component with props', () => {
|
|
25
|
+
subject();
|
|
26
|
+
expect(screen.getByText(`<Component ${JSON.stringify(props)} />`)).toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
test('wraps component within <Provider>', () => {
|
|
29
|
+
subject();
|
|
30
|
+
expect(screen.getByText(`<Provider ${JSON.stringify(stores)} />`)).toBeInTheDocument();
|
|
31
|
+
});
|
|
32
|
+
describe('with fallback options', () => {
|
|
33
|
+
const LoadingFallback = () => null;
|
|
34
|
+
const ErrorFallback = () => null;
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
options = { loadingFallback: _jsx(LoadingFallback, {}), errorFallback: _jsx(ErrorFallback, {}) };
|
|
37
|
+
});
|
|
38
|
+
test('passes fallback options to <Provider>', () => {
|
|
39
|
+
subject();
|
|
40
|
+
expect(screen.getByText(`<Provider ${JSON.stringify({ ...stores, ...options })} />`)).toBeInTheDocument();
|
|
41
|
+
});
|
|
42
|
+
describe('with empty fallback options', () => {
|
|
43
|
+
beforeEach(() => (options = {}));
|
|
44
|
+
test('does not pass options to <Provider>', () => {
|
|
45
|
+
subject();
|
|
46
|
+
expect(screen.getByText(`<Provider ${JSON.stringify({ ...stores })} />`)).toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe('with legacy fallback element', () => {
|
|
51
|
+
const LoadingFallback = () => null;
|
|
52
|
+
beforeEach(() => (options = _jsx(LoadingFallback, {})));
|
|
53
|
+
test('passes {loadingFallback} option', () => {
|
|
54
|
+
subject();
|
|
55
|
+
expect(screen.getByText(`<Provider ${JSON.stringify({
|
|
56
|
+
...stores,
|
|
57
|
+
loadingFallback: _jsx(LoadingFallback, {}),
|
|
58
|
+
})} />`)).toBeInTheDocument();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=provide.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provide.test.js","sourceRoot":"","sources":["../../src/__tests__/provide.test.tsx"],"names":[],"mappings":";AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAM,QAAQ,EAAqB,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5B,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAA0B,EAAE,EAAE;QACzD,OAAO,CACH,MAAC,QAAQ,eACJ,aAAa,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EACvC,QAAQ,IACF,CACd,CAAC;IACN,CAAC;CACJ,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACjC,IAAI,MAAqC,CAAC;IAC1C,IAAI,OAAsC,CAAC;IAC3C,IAAI,KAAsC,CAAC;IAE3C,MAAM,O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1
|
+
{"version":3,"file":"provider.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/provider.test.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import '@testing-library/jest-dom';
|
|
15
|
+
import { act, render, screen, waitFor } from '@testing-library/react';
|
|
16
|
+
import { useEffect } from 'react';
|
|
17
|
+
import { inject, injectable, useDependencies, Store, symbolToken, Provider, } from '..';
|
|
18
|
+
let StatStore = class StatStore {
|
|
19
|
+
constructor() {
|
|
20
|
+
Object.defineProperty(this, "id", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: 'stat'
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(this, "counters", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: {}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(this, "queueCreate", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: []
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(this, "queueRender", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: []
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(this, "testInitialize", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: jest.fn()
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(this, "testDispose", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: jest.fn()
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(this, "testRender", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
configurable: true,
|
|
59
|
+
writable: true,
|
|
60
|
+
value: (id) => {
|
|
61
|
+
this.queueRender.push(id);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
register(name) {
|
|
66
|
+
if (!this.counters[name]) {
|
|
67
|
+
this.counters[name] = 0;
|
|
68
|
+
}
|
|
69
|
+
this.counters[name]++;
|
|
70
|
+
const id = `${name}-${this.counters[name]}`;
|
|
71
|
+
this.queueCreate.push(id);
|
|
72
|
+
return id;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
StatStore = __decorate([
|
|
76
|
+
injectable()
|
|
77
|
+
], StatStore);
|
|
78
|
+
let StoreSimple = class StoreSimple {
|
|
79
|
+
constructor(stat) {
|
|
80
|
+
Object.defineProperty(this, "id", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: void 0
|
|
85
|
+
});
|
|
86
|
+
this.id = stat.register('StoreSimple');
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
StoreSimple = __decorate([
|
|
90
|
+
injectable(),
|
|
91
|
+
__param(0, inject(StatStore)),
|
|
92
|
+
__metadata("design:paramtypes", [StatStore])
|
|
93
|
+
], StoreSimple);
|
|
94
|
+
let StoreWithInitialize = class StoreWithInitialize extends Store {
|
|
95
|
+
constructor(stat) {
|
|
96
|
+
super();
|
|
97
|
+
Object.defineProperty(this, "stat", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
value: stat
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(this, "id", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: true,
|
|
107
|
+
value: void 0
|
|
108
|
+
});
|
|
109
|
+
this.id = stat.register('StoreWithInitialize');
|
|
110
|
+
}
|
|
111
|
+
initialize() {
|
|
112
|
+
this.stat.testInitialize(this.id);
|
|
113
|
+
}
|
|
114
|
+
dispose() {
|
|
115
|
+
this.stat.testDispose(this.id);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
StoreWithInitialize = __decorate([
|
|
119
|
+
injectable(),
|
|
120
|
+
__param(0, inject(StatStore)),
|
|
121
|
+
__metadata("design:paramtypes", [StatStore])
|
|
122
|
+
], StoreWithInitialize);
|
|
123
|
+
const getTestComponent = (inst) => {
|
|
124
|
+
return ({ children }) => {
|
|
125
|
+
const [{ id }, { testRender }] = useDependencies(inst, StatStore);
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
testRender(id);
|
|
128
|
+
}, [testRender, id]);
|
|
129
|
+
return _jsx("div", { children: children });
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
function TestProvider(props) {
|
|
133
|
+
const { singletons, instances, children, store = StoreSimple } = props;
|
|
134
|
+
const Component = getTestComponent(store);
|
|
135
|
+
return (_jsx(Provider, { singletons: singletons, instances: instances, children: _jsx(Component, { children: children }) }));
|
|
136
|
+
}
|
|
137
|
+
describe('[react-ioc] Provider', () => {
|
|
138
|
+
let stat;
|
|
139
|
+
beforeEach(() => (stat = new StatStore()));
|
|
140
|
+
const subject = (children) => render(_jsx(Provider, { singletons: [{ provide: StatStore, useValue: stat }], children: children }));
|
|
141
|
+
const expectQueueRenderToBe = (queueRender) => waitFor(() => {
|
|
142
|
+
expect(stat.queueRender).toEqual(queueRender);
|
|
143
|
+
});
|
|
144
|
+
describe('with singletons', () => {
|
|
145
|
+
test('reuses singletons for each container.get', async () => {
|
|
146
|
+
subject(_jsx(TestProvider, { store: StoreSimple, singletons: [StoreSimple], children: _jsx(TestProvider, { store: StoreSimple }) }));
|
|
147
|
+
expect(stat.queueCreate).toEqual(['StoreSimple-1']);
|
|
148
|
+
await expectQueueRenderToBe(['StoreSimple-1', 'StoreSimple-1']);
|
|
149
|
+
});
|
|
150
|
+
test('creates separate singletons for nested tokens', async () => {
|
|
151
|
+
subject(_jsx(TestProvider, { store: StoreSimple, singletons: [StoreSimple], children: _jsx(TestProvider, { store: StoreSimple, singletons: [StoreSimple] }) }));
|
|
152
|
+
expect(stat.queueCreate).toEqual(['StoreSimple-1', 'StoreSimple-2']);
|
|
153
|
+
await expectQueueRenderToBe(['StoreSimple-1', 'StoreSimple-2']);
|
|
154
|
+
});
|
|
155
|
+
test('reuses inheritable singleton', async () => {
|
|
156
|
+
subject(_jsx(TestProvider, { store: StoreSimple, singletons: [StoreSimple], children: _jsx(TestProvider, { store: StoreSimple, singletons: [{ provide: StoreSimple, inherit: true }] }) }));
|
|
157
|
+
expect(stat.queueCreate).toEqual(['StoreSimple-1']);
|
|
158
|
+
await expectQueueRenderToBe(['StoreSimple-1', 'StoreSimple-1']);
|
|
159
|
+
});
|
|
160
|
+
test('creates singletons when inheritable singleton does not exist', () => {
|
|
161
|
+
subject(_jsx(TestProvider, { store: StoreSimple, singletons: [{ provide: StoreSimple, inherit: true }], children: _jsx(TestProvider, { store: StoreSimple, singletons: [StoreSimple] }) }));
|
|
162
|
+
expect(stat.queueCreate).toEqual(['StoreSimple-1', 'StoreSimple-2']);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
describe('with instances', () => {
|
|
166
|
+
test('creates separate instances for each container.get', async () => {
|
|
167
|
+
subject(_jsx(TestProvider, { store: StoreSimple, instances: [StoreSimple], children: _jsx(TestProvider, { store: StoreSimple }) }));
|
|
168
|
+
expect(stat.queueCreate).toEqual(['StoreSimple-1', 'StoreSimple-2']);
|
|
169
|
+
await expectQueueRenderToBe(['StoreSimple-1', 'StoreSimple-2']);
|
|
170
|
+
});
|
|
171
|
+
test('creates separate instances for nested tokens', async () => {
|
|
172
|
+
subject(_jsx(TestProvider, { store: StoreSimple, instances: [StoreSimple], children: _jsx(TestProvider, { store: StoreSimple, instances: [StoreSimple] }) }));
|
|
173
|
+
expect(stat.queueCreate).toEqual(['StoreSimple-1', 'StoreSimple-2']);
|
|
174
|
+
await expectQueueRenderToBe(['StoreSimple-1', 'StoreSimple-2']);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
describe('useValue', () => {
|
|
178
|
+
const valueToken = symbolToken('valueToken');
|
|
179
|
+
test('creates new values', async () => {
|
|
180
|
+
subject(_jsx(TestProvider, { store: valueToken, singletons: [{ provide: valueToken, useValue: { id: 'value1' } }], children: _jsx(TestProvider, { store: valueToken, singletons: [{ provide: valueToken, useValue: { id: 'value2' } }] }) }));
|
|
181
|
+
await expectQueueRenderToBe(['value1', 'value2']);
|
|
182
|
+
});
|
|
183
|
+
test('reuses nested values', async () => {
|
|
184
|
+
subject(_jsx(TestProvider, { store: valueToken, singletons: [{ provide: valueToken, useValue: { id: 'value1' } }], children: _jsx(TestProvider, { store: valueToken, singletons: [
|
|
185
|
+
{ provide: valueToken, useValue: { id: 'value2' }, inherit: true },
|
|
186
|
+
] }) }));
|
|
187
|
+
await expectQueueRenderToBe(['value1', 'value1']);
|
|
188
|
+
});
|
|
189
|
+
test('does not reuse nested values for instances', async () => {
|
|
190
|
+
subject(_jsx(TestProvider, { store: valueToken, singletons: [{ provide: valueToken, useValue: { id: 'value1' } }], children: _jsx(TestProvider, { store: valueToken, instances: [
|
|
191
|
+
{
|
|
192
|
+
provide: valueToken,
|
|
193
|
+
useValue: { id: 'value2' },
|
|
194
|
+
inherit: true,
|
|
195
|
+
},
|
|
196
|
+
] }) }));
|
|
197
|
+
await expectQueueRenderToBe(['value1', 'value2']);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
describe('check store initialization', () => {
|
|
201
|
+
test('waits for store initialization', async () => {
|
|
202
|
+
subject(_jsx(TestProvider, { store: StoreWithInitialize, singletons: [StoreWithInitialize] }));
|
|
203
|
+
expect(stat.testInitialize).toHaveBeenCalledWith('StoreWithInitialize-1');
|
|
204
|
+
await expectQueueRenderToBe(['StoreWithInitialize-1']);
|
|
205
|
+
});
|
|
206
|
+
test('waits for nested initialization', async () => {
|
|
207
|
+
subject(_jsx(TestProvider, { store: StoreWithInitialize, singletons: [StoreWithInitialize], children: _jsx(TestProvider, { store: StoreWithInitialize, singletons: [StoreWithInitialize] }) }));
|
|
208
|
+
await waitFor(() => {
|
|
209
|
+
expect(stat.testInitialize).toHaveBeenCalledWith('StoreWithInitialize-1');
|
|
210
|
+
});
|
|
211
|
+
await waitFor(() => {
|
|
212
|
+
expect(stat.testInitialize).toHaveBeenCalledWith('StoreWithInitialize-2');
|
|
213
|
+
});
|
|
214
|
+
expect(stat.queueCreate).toEqual(['StoreWithInitialize-1', 'StoreWithInitialize-2']);
|
|
215
|
+
await expectQueueRenderToBe(['StoreWithInitialize-1', 'StoreWithInitialize-2']);
|
|
216
|
+
});
|
|
217
|
+
test('initializes only once when store is reused', async () => {
|
|
218
|
+
subject(_jsx(TestProvider, { store: StoreWithInitialize, singletons: [StoreWithInitialize], children: _jsx(TestProvider, { store: StoreWithInitialize, singletons: [{ provide: StoreWithInitialize, inherit: true }] }) }));
|
|
219
|
+
await waitFor(() => {
|
|
220
|
+
expect(stat.testInitialize).toHaveBeenCalledWith('StoreWithInitialize-1');
|
|
221
|
+
});
|
|
222
|
+
expect(stat.queueCreate).toEqual(['StoreWithInitialize-1']);
|
|
223
|
+
await expectQueueRenderToBe(['StoreWithInitialize-1', 'StoreWithInitialize-1']);
|
|
224
|
+
expect(stat.testInitialize).toHaveBeenCalledTimes(1);
|
|
225
|
+
});
|
|
226
|
+
describe('error initialization', () => {
|
|
227
|
+
beforeAll(() => jest.useFakeTimers());
|
|
228
|
+
afterAll(() => jest.useRealTimers());
|
|
229
|
+
let StoreWithErrorInitialize = class StoreWithErrorInitialize extends Store {
|
|
230
|
+
initialize() {
|
|
231
|
+
throw new Error('error');
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
StoreWithErrorInitialize = __decorate([
|
|
235
|
+
injectable()
|
|
236
|
+
], StoreWithErrorInitialize);
|
|
237
|
+
let StoreWithAsyncErrorInitialize = class StoreWithAsyncErrorInitialize extends Store {
|
|
238
|
+
async initialize() {
|
|
239
|
+
await new Promise(resolve => resolve());
|
|
240
|
+
throw new Error('async error');
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
StoreWithAsyncErrorInitialize = __decorate([
|
|
244
|
+
injectable()
|
|
245
|
+
], StoreWithAsyncErrorInitialize);
|
|
246
|
+
test('async error initialization rethrows and shows error', async () => {
|
|
247
|
+
render(_jsx(Provider, { singletons: [StoreWithAsyncErrorInitialize] }));
|
|
248
|
+
await act(async () => {
|
|
249
|
+
await expect(() => jest.runAllTimersAsync()).rejects.toThrow('async error');
|
|
250
|
+
});
|
|
251
|
+
await waitFor(() => {
|
|
252
|
+
expect(screen.getByText('Error')).toBeInTheDocument();
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
test('sync error initialization rethrows and shows error', async () => {
|
|
256
|
+
render(_jsx(Provider, { singletons: [StoreWithErrorInitialize] }));
|
|
257
|
+
await expect(() => jest.runAllTimersAsync()).rejects.toThrow('error');
|
|
258
|
+
expect(screen.getByText('Error')).toBeInTheDocument();
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
describe('check store dispose', () => {
|
|
263
|
+
test('runs store dispose', () => {
|
|
264
|
+
const { unmount } = subject(_jsx(TestProvider, { store: StoreWithInitialize, singletons: [StoreWithInitialize] }));
|
|
265
|
+
unmount();
|
|
266
|
+
expect(stat.testDispose).toHaveBeenCalledWith('StoreWithInitialize-1');
|
|
267
|
+
});
|
|
268
|
+
test('runs dispose only once when store is reused', async () => {
|
|
269
|
+
const { unmount } = subject(_jsx(TestProvider, { store: StoreWithInitialize, singletons: [StoreWithInitialize], children: _jsx(TestProvider, { store: StoreWithInitialize, singletons: [{ provide: StoreWithInitialize, inherit: true }] }) }));
|
|
270
|
+
expect(stat.queueCreate).toEqual(['StoreWithInitialize-1']);
|
|
271
|
+
await expectQueueRenderToBe(['StoreWithInitialize-1', 'StoreWithInitialize-1']);
|
|
272
|
+
unmount();
|
|
273
|
+
expect(stat.testDispose).toHaveBeenCalledTimes(1);
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
//# sourceMappingURL=provider.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.test.js","sourceRoot":"","sources":["../../src/__tests__/provider.test.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAgC,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EACH,MAAM,EACN,UAAU,EACV,eAAe,EACf,KAAK,EACL,WAAW,EACX,QAAQ,GAEX,MAAM,IAAI,CAAC;AAGZ,IAAM,SAAS,GAAf,MAAM,SAAS;IAAf;QACa;;;;mBAAK,MAAM;WAAC;QACrB;;;;mBAAmC,EAAE;WAAC;QACtC;;;;mBAAwB,EAAE;WAAC;QAC3B;;;;mBAAwB,EAAE;WAAC;QAE3B;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AmB,CAAC,YACvE,KAAC,YAAY,IACT,KAAK,EAAE,mBAAmB,EAC1B,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAC/D,GACS,CAClB,CAAC;YAEF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC;YAC5D,MAAM,qBAAqB,CAAC,CAAC,uBAAuB,EAAE,uBAAuB,CAAC,CAAC,CAAC;YAEhF,OAAO,EAAE,CAAC;YAEV,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-ioc.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/react-ioc.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { render } from '@testing-library/react';
|
|
12
|
+
import { Component, createContext, useRef } from 'react';
|
|
13
|
+
import { provide, injectDependency, Provider, injectable, useDependencies, symbolToken, } from '..';
|
|
14
|
+
import { ContainerContext } from '../common';
|
|
15
|
+
let SampleStore = class SampleStore {
|
|
16
|
+
constructor() {
|
|
17
|
+
Object.defineProperty(this, "singletonVariable", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: 2
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
SampleStore = __decorate([
|
|
26
|
+
injectable()
|
|
27
|
+
], SampleStore);
|
|
28
|
+
const ANOTHER_STORE_TOKEN = symbolToken('ANOTHER_STORE_TOKEN');
|
|
29
|
+
let AnotherStore = class AnotherStore {
|
|
30
|
+
constructor() {
|
|
31
|
+
Object.defineProperty(this, "value", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: '3'
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
AnotherStore = __decorate([
|
|
40
|
+
injectable()
|
|
41
|
+
], AnotherStore);
|
|
42
|
+
const PLAIN_OBJECT_TOKEN = symbolToken('PLAIN_OBJECT_TOKEN');
|
|
43
|
+
class SampleConfig {
|
|
44
|
+
constructor() {
|
|
45
|
+
Object.defineProperty(this, "title", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: void 0
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const SampleConsumer = props => (_jsx(ContainerContext.Consumer, { children: container => {
|
|
54
|
+
props.setContainer(container);
|
|
55
|
+
return props.children;
|
|
56
|
+
} }));
|
|
57
|
+
describe('[react-ioc]', () => {
|
|
58
|
+
test('Context container should bind the provided store', () => {
|
|
59
|
+
let contextContainer;
|
|
60
|
+
const setContainer = (container) => {
|
|
61
|
+
contextContainer = container;
|
|
62
|
+
};
|
|
63
|
+
render(_jsx(Provider, { singletons: [SampleStore, { provide: ANOTHER_STORE_TOKEN, useClass: AnotherStore }], children: _jsx(SampleConsumer, { setContainer: setContainer }) }));
|
|
64
|
+
expect(contextContainer.get(SampleStore)).toBeDefined();
|
|
65
|
+
expect(contextContainer.get(SampleStore).singletonVariable).toBe(2);
|
|
66
|
+
expect(contextContainer.get(ANOTHER_STORE_TOKEN)).toBeDefined();
|
|
67
|
+
expect(contextContainer.get(ANOTHER_STORE_TOKEN).value).toBe('3');
|
|
68
|
+
});
|
|
69
|
+
test('Provide decorator must inject stores to the container', () => {
|
|
70
|
+
let SampleProvider = class SampleProvider extends Component {
|
|
71
|
+
setContainer(container) {
|
|
72
|
+
expect(container.get(SampleStore).singletonVariable).toBe(2);
|
|
73
|
+
}
|
|
74
|
+
render() {
|
|
75
|
+
return _jsx(SampleConsumer, { setContainer: this.setContainer });
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
SampleProvider = __decorate([
|
|
79
|
+
provide({
|
|
80
|
+
singletons: [SampleStore],
|
|
81
|
+
})
|
|
82
|
+
], SampleProvider);
|
|
83
|
+
render(_jsx(SampleProvider, {}));
|
|
84
|
+
});
|
|
85
|
+
test('Unmounted component should unbind the depended store', () => {
|
|
86
|
+
let contextContainer;
|
|
87
|
+
const setContainer = (container) => {
|
|
88
|
+
contextContainer = container;
|
|
89
|
+
};
|
|
90
|
+
const renderer = render(_jsx(Provider, { singletons: [
|
|
91
|
+
SampleStore,
|
|
92
|
+
{ provide: ANOTHER_STORE_TOKEN, useClass: AnotherStore },
|
|
93
|
+
{ provide: PLAIN_OBJECT_TOKEN, useValue: { success: true } },
|
|
94
|
+
], children: _jsx(SampleConsumer, { setContainer: setContainer }) }));
|
|
95
|
+
renderer.unmount();
|
|
96
|
+
expect(() => contextContainer.get(SampleStore)).toThrow();
|
|
97
|
+
expect(() => contextContainer.get(ANOTHER_STORE_TOKEN)).toThrow();
|
|
98
|
+
expect(() => contextContainer.get(PLAIN_OBJECT_TOKEN)).toThrow();
|
|
99
|
+
});
|
|
100
|
+
test('Injected store in transient scope should not retain change', () => {
|
|
101
|
+
let contextContainer;
|
|
102
|
+
const setContainer = (container) => {
|
|
103
|
+
contextContainer = container;
|
|
104
|
+
};
|
|
105
|
+
render(_jsx(Provider, { instances: [SampleStore], children: _jsx(SampleConsumer, { setContainer: setContainer }) }));
|
|
106
|
+
expect(contextContainer.get(SampleStore)).toBeDefined();
|
|
107
|
+
expect(contextContainer.get(SampleStore).singletonVariable).toBe(2);
|
|
108
|
+
contextContainer.get(SampleStore).singletonVariable = 42;
|
|
109
|
+
expect(contextContainer.get(SampleStore).singletonVariable).toBe(2);
|
|
110
|
+
});
|
|
111
|
+
test('Child with same singleton store should have different version of store', () => {
|
|
112
|
+
let parentContainer;
|
|
113
|
+
let childContainer;
|
|
114
|
+
const setParentContainer = (container) => {
|
|
115
|
+
parentContainer = container;
|
|
116
|
+
};
|
|
117
|
+
const setChildContainer = (container) => {
|
|
118
|
+
childContainer = container;
|
|
119
|
+
};
|
|
120
|
+
render(_jsx(Provider, { singletons: [SampleStore], children: _jsx(SampleConsumer, { setContainer: setParentContainer, children: _jsx(Provider, { singletons: [SampleStore], children: _jsx(SampleConsumer, { setContainer: setChildContainer }) }) }) }));
|
|
121
|
+
const parentStore = parentContainer.get(SampleStore);
|
|
122
|
+
const childStore = childContainer.get(SampleStore);
|
|
123
|
+
expect(childStore === parentStore).toBe(false);
|
|
124
|
+
});
|
|
125
|
+
test('Child should be able to access stores in parent scope', () => {
|
|
126
|
+
let parentContainer;
|
|
127
|
+
let childContainer;
|
|
128
|
+
const setParentContainer = (container) => {
|
|
129
|
+
parentContainer = container;
|
|
130
|
+
parentContainer.get(SampleStore).singletonVariable = 4;
|
|
131
|
+
};
|
|
132
|
+
const setChildContainer = (container) => {
|
|
133
|
+
childContainer = container;
|
|
134
|
+
};
|
|
135
|
+
render(_jsx(Provider, { singletons: [SampleStore], children: _jsx(SampleConsumer, { setContainer: setParentContainer, children: _jsx(Provider, { children: _jsx(SampleConsumer, { setContainer: setChildContainer }) }) }) }));
|
|
136
|
+
const childStore = childContainer.get(SampleStore);
|
|
137
|
+
expect(childStore.singletonVariable).toBe(4);
|
|
138
|
+
});
|
|
139
|
+
test('injected store must be initialized properly', () => {
|
|
140
|
+
class SampleComponent extends Component {
|
|
141
|
+
componentDidMount() {
|
|
142
|
+
expect(this.sampleStore.singletonVariable).toBe(2);
|
|
143
|
+
}
|
|
144
|
+
render() {
|
|
145
|
+
return _jsx("h1", { children: "Hakunamatata" });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
__decorate([
|
|
149
|
+
injectDependency(SampleStore),
|
|
150
|
+
__metadata("design:type", SampleStore)
|
|
151
|
+
], SampleComponent.prototype, "sampleStore", void 0);
|
|
152
|
+
render(_jsx(Provider, { singletons: [SampleStore], children: _jsx(SampleComponent, {}) }));
|
|
153
|
+
});
|
|
154
|
+
test('store injection must throw an error if custom contextType is present', () => {
|
|
155
|
+
expect(() => {
|
|
156
|
+
class SampleComponent extends Component {
|
|
157
|
+
render() {
|
|
158
|
+
return _jsx("h1", { children: "Hakunamatata" });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
Object.defineProperty(SampleComponent, "contextType", {
|
|
162
|
+
enumerable: true,
|
|
163
|
+
configurable: true,
|
|
164
|
+
writable: true,
|
|
165
|
+
value: createContext({})
|
|
166
|
+
});
|
|
167
|
+
__decorate([
|
|
168
|
+
injectDependency(SampleStore),
|
|
169
|
+
__metadata("design:type", SampleStore)
|
|
170
|
+
], SampleComponent.prototype, "sampleStore", void 0);
|
|
171
|
+
render(_jsx(Provider, { singletons: [SampleStore], children: _jsx(SampleComponent, {}) }));
|
|
172
|
+
}).toThrow();
|
|
173
|
+
});
|
|
174
|
+
test('store injection must throw an error if React context is not passed to constructor', () => {
|
|
175
|
+
jest.spyOn(console, 'error').mockImplementation(jest.fn()); // suppress "context doesn't exist" error
|
|
176
|
+
expect(() => {
|
|
177
|
+
class SampleComponent extends Component {
|
|
178
|
+
constructor(props) {
|
|
179
|
+
super(props);
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
181
|
+
this.sampleStore.singletonVariable;
|
|
182
|
+
}
|
|
183
|
+
render() {
|
|
184
|
+
return _jsx("h1", { children: "Hakunamatata" });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
__decorate([
|
|
188
|
+
injectDependency(SampleStore),
|
|
189
|
+
__metadata("design:type", SampleStore)
|
|
190
|
+
], SampleComponent.prototype, "sampleStore", void 0);
|
|
191
|
+
render(_jsx(Provider, { singletons: [SampleStore], children: _jsx(SampleComponent, {}) }));
|
|
192
|
+
}).toThrow("Context doesn't exist on a target class. Please make sure to pass context object to super method if you access injectable stores in constructor.");
|
|
193
|
+
});
|
|
194
|
+
test('store in singleton scope usage with hooks must be initialized properly', () => {
|
|
195
|
+
const SampleComponent = () => {
|
|
196
|
+
const [sampleStore, anotherStore, plainObject, sampleConfig] = useDependencies(SampleStore, ANOTHER_STORE_TOKEN, PLAIN_OBJECT_TOKEN, SampleConfig);
|
|
197
|
+
expect(sampleStore.singletonVariable).toBe(2);
|
|
198
|
+
expect(anotherStore.value).toBe('3');
|
|
199
|
+
expect(plainObject.success).toBe(true);
|
|
200
|
+
expect(sampleConfig.title).toBe('Title 1');
|
|
201
|
+
const storeRef = useRef(sampleStore);
|
|
202
|
+
expect(storeRef.current === sampleStore).toBe(true);
|
|
203
|
+
return _jsx("h1", { children: "It works" });
|
|
204
|
+
};
|
|
205
|
+
const Component = () => (_jsx(Provider, { singletons: [
|
|
206
|
+
SampleStore,
|
|
207
|
+
{ provide: ANOTHER_STORE_TOKEN, useClass: AnotherStore },
|
|
208
|
+
{ provide: PLAIN_OBJECT_TOKEN, useValue: { success: true } },
|
|
209
|
+
{ provide: SampleConfig, useValue: { title: 'Title 1' } },
|
|
210
|
+
], children: _jsx(SampleComponent, {}) }));
|
|
211
|
+
const renderer = render(_jsx(Component, {}));
|
|
212
|
+
renderer.rerender(_jsx(Component, {}));
|
|
213
|
+
});
|
|
214
|
+
test('store in transient scope usage with hooks must be initialized properly', () => {
|
|
215
|
+
const SampleComponent = () => {
|
|
216
|
+
const [sampleStore] = useDependencies(SampleStore);
|
|
217
|
+
expect(sampleStore.singletonVariable).toBe(2);
|
|
218
|
+
const storeRef = useRef(sampleStore);
|
|
219
|
+
expect(storeRef.current === sampleStore).toBe(true);
|
|
220
|
+
return _jsx("h1", { children: "It works" });
|
|
221
|
+
};
|
|
222
|
+
const Component = () => (_jsx(Provider, { instances: [SampleStore], children: _jsx(SampleComponent, {}) }));
|
|
223
|
+
const renderer = render(_jsx(Component, {}));
|
|
224
|
+
renderer.rerender(_jsx(Component, {}));
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
//# sourceMappingURL=react-ioc.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-ioc.test.js","sourceRoot":"","sources":["../../src/__tests__/react-ioc.test.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAyB,MAAM,OAAO,CAAC;AAChF,OAAO,EACH,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,UAAU,EAEV,eAAe,EACf,WAAW,GACd,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,IAAM,WAAW,GAAjB,MAAM,WAAW;IAAjB;QACI;;;;mBAAoB,CAAC;WAAC;IAC1B,CAAC;CAAA,CAAA;AAFK,WAAW;IADhB,UAAU,EAAE;GACP,WAAW,CAEhB;AAMD,MAAM,mBAAmB,GAAG,WAAW,CAAgB,qBAAqB,CAAC,CAAC;AAG9E,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACI;;;;mBAAQ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AAC,OAA0C,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,eAAe,CAAkB,GAAG,MAAiB;IACjE,OAAO,uBAAuB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAkB,GAAG,MAAiB;IACzE,OAAO,uBAAuB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/react-ioc",
|
|
3
|
-
"version": "28.
|
|
3
|
+
"version": "28.3.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/react-ioc",
|
|
6
6
|
"repository": {
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"src"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"inversify": "~6.1
|
|
18
|
+
"inversify": "~6.2.1",
|
|
19
19
|
"reflect-metadata": "~0.2.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@testing-library/dom": "^10.4.0",
|
|
23
23
|
"@testing-library/jest-dom": "^6.6.3",
|
|
24
|
-
"@testing-library/react": "^16.0
|
|
24
|
+
"@testing-library/react": "^16.1.0",
|
|
25
25
|
"@types/react": "~18.3.3",
|
|
26
26
|
"react": "~18.3.1"
|
|
27
27
|
},
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"cli": {
|
|
35
35
|
"webpack": false
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "63ce3ca18966fc5522a3b61df5e4c55f82b4272e"
|
|
38
38
|
}
|
package/src/use-dependencies.ts
CHANGED