@sprucelabs/spruce-heartwood-utils 19.6.1 → 19.6.2
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/build/__tests__/support/MockRemoteViewControllerFactory.d.ts +4 -1
- package/build/__tests__/support/MockRemoteViewControllerFactory.js +21 -3
- package/build/esm/__tests__/support/MockRemoteViewControllerFactory.d.ts +4 -1
- package/build/esm/__tests__/support/MockRemoteViewControllerFactory.js +21 -3
- package/package.json +1 -1
|
@@ -5,12 +5,14 @@ export default class MockRemoteViewControllerFactory implements RemoteViewContro
|
|
|
5
5
|
private loadedControllers;
|
|
6
6
|
private remoteControllerOptions?;
|
|
7
7
|
private views;
|
|
8
|
+
private static controllers?;
|
|
8
9
|
constructor(options: RemoteFactoryOptions);
|
|
9
10
|
fetchRemoteController(_name: string): Promise<(new () => ViewController<any>) & {
|
|
10
11
|
id: string;
|
|
11
12
|
}>;
|
|
12
13
|
Controller<N extends keyof ViewControllerMap, O extends ControllerOptions<N>>(_name: N, _options: O): ViewControllerMap[N];
|
|
13
|
-
dropInRemoteController(id: string, Class: new (args: any) => ViewController<any>): void;
|
|
14
|
+
static dropInRemoteController(id: string, Class: new (args: any) => ViewController<any>): void;
|
|
15
|
+
private static dropInControllers;
|
|
14
16
|
assertSkillViewRendersRemoteCard(vc: SkillViewController, id: string): void;
|
|
15
17
|
static reset(): void;
|
|
16
18
|
static getInstance(): MockRemoteViewControllerFactory;
|
|
@@ -20,3 +22,4 @@ export default class MockRemoteViewControllerFactory implements RemoteViewContro
|
|
|
20
22
|
hasController(name: string): boolean;
|
|
21
23
|
RemoteController(name: string, options: Record<string, any>): Promise<any>;
|
|
22
24
|
}
|
|
25
|
+
export type MockDroppedInControllers = Record<string, new (args: any) => ViewController<any>>;
|
|
@@ -7,15 +7,32 @@ class MockRemoteViewControllerFactory {
|
|
|
7
7
|
this.loadedControllers = {};
|
|
8
8
|
MockRemoteViewControllerFactory.instance = this;
|
|
9
9
|
this.views = options.vcFactory;
|
|
10
|
+
MockRemoteViewControllerFactory.dropInControllers(this);
|
|
10
11
|
}
|
|
11
12
|
fetchRemoteController(_name) {
|
|
12
|
-
throw new Error('
|
|
13
|
+
throw new Error('Not implemented in mock.');
|
|
13
14
|
}
|
|
14
15
|
Controller(_name, _options) {
|
|
15
16
|
return {};
|
|
16
17
|
}
|
|
17
|
-
dropInRemoteController(id, Class) {
|
|
18
|
-
this.
|
|
18
|
+
static dropInRemoteController(id, Class) {
|
|
19
|
+
if (!this.controllers) {
|
|
20
|
+
this.controllers = {};
|
|
21
|
+
}
|
|
22
|
+
this.controllers[id] = Class;
|
|
23
|
+
if (this.instance) {
|
|
24
|
+
const instance = this.instance;
|
|
25
|
+
this.dropInControllers(instance);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
static dropInControllers(instance) {
|
|
29
|
+
const controllers = this.controllers;
|
|
30
|
+
if (controllers) {
|
|
31
|
+
for (const key of Object.keys(controllers)) {
|
|
32
|
+
const vc = controllers[key];
|
|
33
|
+
instance.views.setController(key, vc);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
19
36
|
}
|
|
20
37
|
assertSkillViewRendersRemoteCard(vc, id) {
|
|
21
38
|
const cards = heartwood_view_controllers_1.vcAssert.assertSkillViewRendersCards(vc);
|
|
@@ -25,6 +42,7 @@ class MockRemoteViewControllerFactory {
|
|
|
25
42
|
}
|
|
26
43
|
static reset() {
|
|
27
44
|
delete this.instance;
|
|
45
|
+
delete this.controllers;
|
|
28
46
|
}
|
|
29
47
|
static getInstance() {
|
|
30
48
|
if (!this.instance) {
|
|
@@ -5,12 +5,14 @@ export default class MockRemoteViewControllerFactory implements RemoteViewContro
|
|
|
5
5
|
private loadedControllers;
|
|
6
6
|
private remoteControllerOptions?;
|
|
7
7
|
private views;
|
|
8
|
+
private static controllers?;
|
|
8
9
|
constructor(options: RemoteFactoryOptions);
|
|
9
10
|
fetchRemoteController(_name: string): Promise<(new () => ViewController<any>) & {
|
|
10
11
|
id: string;
|
|
11
12
|
}>;
|
|
12
13
|
Controller<N extends keyof ViewControllerMap, O extends ControllerOptions<N>>(_name: N, _options: O): ViewControllerMap[N];
|
|
13
|
-
dropInRemoteController(id: string, Class: new (args: any) => ViewController<any>): void;
|
|
14
|
+
static dropInRemoteController(id: string, Class: new (args: any) => ViewController<any>): void;
|
|
15
|
+
private static dropInControllers;
|
|
14
16
|
assertSkillViewRendersRemoteCard(vc: SkillViewController, id: string): void;
|
|
15
17
|
static reset(): void;
|
|
16
18
|
static getInstance(): MockRemoteViewControllerFactory;
|
|
@@ -20,3 +22,4 @@ export default class MockRemoteViewControllerFactory implements RemoteViewContro
|
|
|
20
22
|
hasController(name: string): boolean;
|
|
21
23
|
RemoteController(name: string, options: Record<string, any>): Promise<any>;
|
|
22
24
|
}
|
|
25
|
+
export type MockDroppedInControllers = Record<string, new (args: any) => ViewController<any>>;
|
|
@@ -14,15 +14,32 @@ export default class MockRemoteViewControllerFactory {
|
|
|
14
14
|
this.loadedControllers = {};
|
|
15
15
|
MockRemoteViewControllerFactory.instance = this;
|
|
16
16
|
this.views = options.vcFactory;
|
|
17
|
+
MockRemoteViewControllerFactory.dropInControllers(this);
|
|
17
18
|
}
|
|
18
19
|
fetchRemoteController(_name) {
|
|
19
|
-
throw new Error('
|
|
20
|
+
throw new Error('Not implemented in mock.');
|
|
20
21
|
}
|
|
21
22
|
Controller(_name, _options) {
|
|
22
23
|
return {};
|
|
23
24
|
}
|
|
24
|
-
dropInRemoteController(id, Class) {
|
|
25
|
-
this.
|
|
25
|
+
static dropInRemoteController(id, Class) {
|
|
26
|
+
if (!this.controllers) {
|
|
27
|
+
this.controllers = {};
|
|
28
|
+
}
|
|
29
|
+
this.controllers[id] = Class;
|
|
30
|
+
if (this.instance) {
|
|
31
|
+
const instance = this.instance;
|
|
32
|
+
this.dropInControllers(instance);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
static dropInControllers(instance) {
|
|
36
|
+
const controllers = this.controllers;
|
|
37
|
+
if (controllers) {
|
|
38
|
+
for (const key of Object.keys(controllers)) {
|
|
39
|
+
const vc = controllers[key];
|
|
40
|
+
instance.views.setController(key, vc);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
26
43
|
}
|
|
27
44
|
assertSkillViewRendersRemoteCard(vc, id) {
|
|
28
45
|
const cards = vcAssert.assertSkillViewRendersCards(vc);
|
|
@@ -32,6 +49,7 @@ export default class MockRemoteViewControllerFactory {
|
|
|
32
49
|
}
|
|
33
50
|
static reset() {
|
|
34
51
|
delete this.instance;
|
|
52
|
+
delete this.controllers;
|
|
35
53
|
}
|
|
36
54
|
static getInstance() {
|
|
37
55
|
if (!this.instance) {
|