@sprucelabs/spruce-heartwood-utils 38.17.4 → 38.17.5
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/app/SkillViewEmitter.d.ts +167 -0
- package/build/app/SkillViewEmitter.js +69 -0
- package/build/esm/__tests__/support/MockRemoteViewControllerFactory.js +13 -29
- package/build/esm/__tests__/support/heartwoodEventFaker.js +20 -31
- package/build/esm/__tests__/support/remoteVcAssert.js +51 -63
- package/build/esm/app/SkillViewEmitter.d.ts +167 -0
- package/build/esm/app/SkillViewEmitter.js +65 -0
- package/build/esm/components/DelayedPlacer.js +11 -15
- package/build/esm/components/Settings.js +1 -2
- package/build/esm/components/Sizer.js +12 -30
- package/build/esm/components/animation/DelayedPlacerExport.js +2 -14
- package/build/esm/components/animation/SimpleEmitter.js +3 -6
- package/build/esm/components/animation/SizerExport.js +6 -27
- package/build/esm/devices/HeartwoodDevice.js +34 -52
- package/build/esm/errors/SpruceError.js +1 -1
- package/build/esm/hooks/queueShow.js +6 -7
- package/build/esm/index-testing.d.ts +6 -0
- package/build/esm/index-testing.js +4 -0
- package/build/esm/index-web.d.ts +11 -0
- package/build/esm/index-web.js +7 -0
- package/build/esm/theming/ThemeManager.js +55 -82
- package/build/esm/theming/loadActiveThemeForOrg.js +6 -17
- package/build/esm/views/CardRegistrar.js +46 -58
- package/build/esm/views/RemoteViewControllerFactory.js +60 -76
- package/build/index-testing.d.ts +6 -0
- package/build/index-testing.js +15 -0
- package/build/index-web.d.ts +11 -0
- package/build/index-web.js +33 -0
- package/package.json +34 -2
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { AbstractEventEmitter } from '@sprucelabs/mercury-event-emitter';
|
|
2
|
+
import { EventContract, EventContractEmitPayloads, MercuryEventEmitter } from '@sprucelabs/mercury-types';
|
|
3
|
+
declare const contract: {
|
|
4
|
+
eventSignatures: {
|
|
5
|
+
'did-change-orientation': {};
|
|
6
|
+
'did-resize': {};
|
|
7
|
+
'did-render': {};
|
|
8
|
+
'did-resize-content': {};
|
|
9
|
+
'did-place-cards': {};
|
|
10
|
+
'will-change-route': {};
|
|
11
|
+
'did-render-dialog': {};
|
|
12
|
+
'did-keydown': {
|
|
13
|
+
emitPayloadSchema: {
|
|
14
|
+
id: string;
|
|
15
|
+
fields: {
|
|
16
|
+
e: {
|
|
17
|
+
type: "raw";
|
|
18
|
+
isRequired: true;
|
|
19
|
+
options: {
|
|
20
|
+
valueType: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
'did-scroll': {
|
|
27
|
+
emitPayloadSchema: {
|
|
28
|
+
id: string;
|
|
29
|
+
fields: {
|
|
30
|
+
scrollTop: {
|
|
31
|
+
type: "number";
|
|
32
|
+
isRequired: true;
|
|
33
|
+
};
|
|
34
|
+
skillViewNode: {
|
|
35
|
+
type: "raw";
|
|
36
|
+
isRequired: true;
|
|
37
|
+
options: {
|
|
38
|
+
valueType: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
'connection-status-change': {
|
|
45
|
+
emitPayloadSchema: {
|
|
46
|
+
id: string;
|
|
47
|
+
fields: {
|
|
48
|
+
payload: {
|
|
49
|
+
type: "schema";
|
|
50
|
+
isRequired: true;
|
|
51
|
+
options: {
|
|
52
|
+
schema: {
|
|
53
|
+
id: string;
|
|
54
|
+
fields: {
|
|
55
|
+
status: {
|
|
56
|
+
type: "select";
|
|
57
|
+
isRequired: true;
|
|
58
|
+
options: {
|
|
59
|
+
choices: ({
|
|
60
|
+
readonly label: "Connecting";
|
|
61
|
+
readonly value: "connecting";
|
|
62
|
+
} | {
|
|
63
|
+
readonly label: "Connected";
|
|
64
|
+
readonly value: "connected";
|
|
65
|
+
} | {
|
|
66
|
+
readonly label: "Disconnected";
|
|
67
|
+
readonly value: "disconnected";
|
|
68
|
+
})[];
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
export type SkillViewEventContract = typeof contract;
|
|
81
|
+
export type SkillViewEvents = SkillViewEventContract['eventSignatures'];
|
|
82
|
+
export type SkillViewEmitPayloads = EventContractEmitPayloads<SkillViewEventContract>;
|
|
83
|
+
export type SkillViewEmitter = MercuryEventEmitter<SkillViewEventContract>;
|
|
84
|
+
export default class SkillViewEmitterImpl<Contract extends EventContract = SkillViewEventContract> extends AbstractEventEmitter<Contract> implements MercuryEventEmitter<Contract> {
|
|
85
|
+
private static instance;
|
|
86
|
+
private constructor();
|
|
87
|
+
static Emitter(): SkillViewEmitterImpl<{
|
|
88
|
+
eventSignatures: {
|
|
89
|
+
'did-change-orientation': {};
|
|
90
|
+
'did-resize': {};
|
|
91
|
+
'did-render': {};
|
|
92
|
+
'did-resize-content': {};
|
|
93
|
+
'did-place-cards': {};
|
|
94
|
+
'will-change-route': {};
|
|
95
|
+
'did-render-dialog': {};
|
|
96
|
+
'did-keydown': {
|
|
97
|
+
emitPayloadSchema: {
|
|
98
|
+
id: string;
|
|
99
|
+
fields: {
|
|
100
|
+
e: {
|
|
101
|
+
type: "raw";
|
|
102
|
+
isRequired: true;
|
|
103
|
+
options: {
|
|
104
|
+
valueType: string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
'did-scroll': {
|
|
111
|
+
emitPayloadSchema: {
|
|
112
|
+
id: string;
|
|
113
|
+
fields: {
|
|
114
|
+
scrollTop: {
|
|
115
|
+
type: "number";
|
|
116
|
+
isRequired: true;
|
|
117
|
+
};
|
|
118
|
+
skillViewNode: {
|
|
119
|
+
type: "raw";
|
|
120
|
+
isRequired: true;
|
|
121
|
+
options: {
|
|
122
|
+
valueType: string;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
'connection-status-change': {
|
|
129
|
+
emitPayloadSchema: {
|
|
130
|
+
id: string;
|
|
131
|
+
fields: {
|
|
132
|
+
payload: {
|
|
133
|
+
type: "schema";
|
|
134
|
+
isRequired: true;
|
|
135
|
+
options: {
|
|
136
|
+
schema: {
|
|
137
|
+
id: string;
|
|
138
|
+
fields: {
|
|
139
|
+
status: {
|
|
140
|
+
type: "select";
|
|
141
|
+
isRequired: true;
|
|
142
|
+
options: {
|
|
143
|
+
choices: ({
|
|
144
|
+
readonly label: "Connecting";
|
|
145
|
+
readonly value: "connecting";
|
|
146
|
+
} | {
|
|
147
|
+
readonly label: "Connected";
|
|
148
|
+
readonly value: "connected";
|
|
149
|
+
} | {
|
|
150
|
+
readonly label: "Disconnected";
|
|
151
|
+
readonly value: "disconnected";
|
|
152
|
+
})[];
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
}>;
|
|
164
|
+
static reset(): void;
|
|
165
|
+
static getInstance(): SkillViewEmitter;
|
|
166
|
+
}
|
|
167
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const mercury_client_1 = require("@sprucelabs/mercury-client");
|
|
4
|
+
const mercury_event_emitter_1 = require("@sprucelabs/mercury-event-emitter");
|
|
5
|
+
const mercury_types_1 = require("@sprucelabs/mercury-types");
|
|
6
|
+
const schema_1 = require("@sprucelabs/schema");
|
|
7
|
+
const contract = (0, mercury_types_1.buildEventContract)({
|
|
8
|
+
eventSignatures: {
|
|
9
|
+
...mercury_client_1.connectionStatusContract.eventSignatures,
|
|
10
|
+
'did-change-orientation': {},
|
|
11
|
+
'did-resize': {},
|
|
12
|
+
'did-render': {},
|
|
13
|
+
'did-resize-content': {},
|
|
14
|
+
'did-place-cards': {},
|
|
15
|
+
'will-change-route': {},
|
|
16
|
+
'did-render-dialog': {},
|
|
17
|
+
'did-keydown': {
|
|
18
|
+
emitPayloadSchema: (0, schema_1.buildSchema)({
|
|
19
|
+
id: 'didKeydownEmitPayload',
|
|
20
|
+
fields: {
|
|
21
|
+
e: {
|
|
22
|
+
type: 'raw',
|
|
23
|
+
isRequired: true,
|
|
24
|
+
options: {
|
|
25
|
+
valueType: 'KeyboardEvent',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
'did-scroll': {
|
|
32
|
+
emitPayloadSchema: (0, schema_1.buildSchema)({
|
|
33
|
+
id: 'didScrollEmitPayload',
|
|
34
|
+
fields: {
|
|
35
|
+
scrollTop: {
|
|
36
|
+
type: 'number',
|
|
37
|
+
isRequired: true,
|
|
38
|
+
},
|
|
39
|
+
skillViewNode: {
|
|
40
|
+
type: 'raw',
|
|
41
|
+
isRequired: true,
|
|
42
|
+
options: {
|
|
43
|
+
valueType: 'HTMLDivElement',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
class SkillViewEmitterImpl extends mercury_event_emitter_1.AbstractEventEmitter {
|
|
52
|
+
constructor(contract) {
|
|
53
|
+
super(contract);
|
|
54
|
+
}
|
|
55
|
+
static Emitter() {
|
|
56
|
+
return new this(contract);
|
|
57
|
+
}
|
|
58
|
+
static reset() {
|
|
59
|
+
this.instance = null;
|
|
60
|
+
}
|
|
61
|
+
static getInstance() {
|
|
62
|
+
if (!this.instance) {
|
|
63
|
+
this.instance = this.Emitter();
|
|
64
|
+
}
|
|
65
|
+
return this.instance;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.default = SkillViewEmitterImpl;
|
|
69
|
+
//# sourceMappingURL=SkillViewEmitter.js.map
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { vcAssert, } from '@sprucelabs/heartwood-view-controllers';
|
|
11
2
|
import { assert } from '@sprucelabs/test-utils';
|
|
12
3
|
class MockRemoteViewControllerFactory {
|
|
@@ -45,8 +36,7 @@ class MockRemoteViewControllerFactory {
|
|
|
45
36
|
}
|
|
46
37
|
}
|
|
47
38
|
assertSkillViewRendersRemoteCard(vc, name, id) {
|
|
48
|
-
|
|
49
|
-
const Class = (_a = MockRemoteViewControllerFactory.controllers) === null || _a === void 0 ? void 0 : _a[name];
|
|
39
|
+
const Class = MockRemoteViewControllerFactory.controllers?.[name];
|
|
50
40
|
assert.isTruthy(Class, `You did not drop in a remote card with the name '${name}'! Try MockRemoteViewControllerFactory.dropInRemoteController('${name}', Class) in your beforeEach().`);
|
|
51
41
|
const cards = vcAssert.assertSkillViewRendersCards(vc);
|
|
52
42
|
const cardsWithNoControllers = cards.filter((c) => !c);
|
|
@@ -92,7 +82,7 @@ class MockRemoteViewControllerFactory {
|
|
|
92
82
|
try {
|
|
93
83
|
this.assertFetchedRemoteController(id);
|
|
94
84
|
}
|
|
95
|
-
catch
|
|
85
|
+
catch {
|
|
96
86
|
return;
|
|
97
87
|
}
|
|
98
88
|
assert.fail(`You fetched the controller with the id '${id}' but you should not have.`);
|
|
@@ -107,23 +97,17 @@ class MockRemoteViewControllerFactory {
|
|
|
107
97
|
assert.isEqualDeep(this.constructorOptionsById[id], expected, `The constructor options for the remote card with id '${id}' do not match the expected options. Make sure the card you are rendering has an id using this.views.Controller('card', { id })`);
|
|
108
98
|
}
|
|
109
99
|
hasController(name) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
loadViewsForNamespace(namespace) {
|
|
124
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
this.loadedNamespaces[namespace] = true;
|
|
126
|
-
});
|
|
100
|
+
return this.loadedControllers[name] ?? false;
|
|
101
|
+
}
|
|
102
|
+
async RemoteController(id, options) {
|
|
103
|
+
assert.isTruthy(MockRemoteViewControllerFactory.controllers?.[id], `Could not find a remote card with the id '${id}'! Try MockRemoteViewControllerFactory.dropInRemoteController('${id}', Class) in your beforeEach().`);
|
|
104
|
+
this.loadedControllers[id] = true;
|
|
105
|
+
this.constructorOptionsById[options.id ?? id] = options;
|
|
106
|
+
this.lastRemoteCostructorOptions = options;
|
|
107
|
+
return this.views.Controller(id, options);
|
|
108
|
+
}
|
|
109
|
+
async loadViewsForNamespace(namespace) {
|
|
110
|
+
this.loadedNamespaces[namespace] = true;
|
|
127
111
|
}
|
|
128
112
|
assertLoadedViewsForNamespace(namespace) {
|
|
129
113
|
assert.isTrue(this.loadedNamespaces[namespace], `You did not load views for the namespace '${namespace}'. Try removeVc.loadViewsForNamespace('${namespace}').`);
|
|
@@ -1,36 +1,25 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { eventFaker } from '@sprucelabs/spruce-test-fixtures';
|
|
11
2
|
import { generateId } from '@sprucelabs/test-utils';
|
|
12
3
|
const heartwoodEventFaker = {
|
|
13
|
-
fakeGetViews(svcIds, stubMethodToImplement) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
});
|
|
4
|
+
async fakeGetViews(svcIds, stubMethodToImplement) {
|
|
5
|
+
const vcs = svcIds.map((id) => ({
|
|
6
|
+
id,
|
|
7
|
+
stubMethod: stubMethodToImplement,
|
|
8
|
+
}));
|
|
9
|
+
const source = [
|
|
10
|
+
...vcs.map((vc, idx) => generateVcSource({
|
|
11
|
+
vcId: vc.id,
|
|
12
|
+
count: idx + 1,
|
|
13
|
+
stubMethod: vc.stubMethod,
|
|
14
|
+
})),
|
|
15
|
+
`heartwood({ ${vcs.map((vc, idx) => `TestEventViewController${idx + 1}`)} })`,
|
|
16
|
+
];
|
|
17
|
+
await eventFaker.on('heartwood.get-skill-views::v2021_02_11', () => {
|
|
18
|
+
return {
|
|
19
|
+
id: generateId(),
|
|
20
|
+
ids: svcIds,
|
|
21
|
+
source: source.join('\n'),
|
|
22
|
+
};
|
|
34
23
|
});
|
|
35
24
|
},
|
|
36
25
|
};
|
|
@@ -40,7 +29,7 @@ function generateVcSource(options) {
|
|
|
40
29
|
return [
|
|
41
30
|
`class TestEventViewController${count} {
|
|
42
31
|
alert = function() {}
|
|
43
|
-
${stubMethod
|
|
32
|
+
${stubMethod ?? 'noop'} = function () {
|
|
44
33
|
this.wasHit = true
|
|
45
34
|
this.passedParams = Array.prototype.slice.call(arguments)
|
|
46
35
|
}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { AbstractViewController, vcAssert, } from '@sprucelabs/heartwood-view-controllers';
|
|
11
2
|
import { assertOptions } from '@sprucelabs/schema';
|
|
12
3
|
import { eventFaker, } from '@sprucelabs/spruce-test-fixtures';
|
|
@@ -14,48 +5,46 @@ import { assert } from '@sprucelabs/test-utils';
|
|
|
14
5
|
import { generateId } from '@sprucelabs/test-utils';
|
|
15
6
|
import heartwoodEventFaker from './heartwoodEventFaker.js';
|
|
16
7
|
const remoteVcAssert = {
|
|
17
|
-
assertSkillViewRendersRemoteCards(options) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
assert.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
catch (err) {
|
|
58
|
-
assert.fail(`You didn't drop in the cards to your skill view! Make sure your vcIdsTransformer looks something like:
|
|
8
|
+
async assertSkillViewRendersRemoteCards(options) {
|
|
9
|
+
const { views, svc: svc, expectedTarget, expectedPayload, fqen, shouldInvoke, loadArgs, } = assertOptions(options, [
|
|
10
|
+
'svc',
|
|
11
|
+
'fqen',
|
|
12
|
+
'views',
|
|
13
|
+
]);
|
|
14
|
+
const factory = views.getFactory();
|
|
15
|
+
factory.setController('heartwood.error-card', ThrowingErrorCardVc);
|
|
16
|
+
const vc1Id = generateId();
|
|
17
|
+
const vc2Id = generateId();
|
|
18
|
+
let wasHit = false;
|
|
19
|
+
let passedTarget;
|
|
20
|
+
let passedPayload;
|
|
21
|
+
await eventFaker.on(fqen,
|
|
22
|
+
//@ts-ignore
|
|
23
|
+
async ({ target, payload } = {}) => {
|
|
24
|
+
passedTarget = target;
|
|
25
|
+
passedPayload = payload;
|
|
26
|
+
wasHit = true;
|
|
27
|
+
return {
|
|
28
|
+
vcIds: ['assert.' + vc1Id, 'assert.' + vc2Id],
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
const stubMethodName = shouldInvoke?.methodName;
|
|
32
|
+
const ids = [vc1Id, vc2Id];
|
|
33
|
+
await heartwoodEventFaker.fakeGetViews(ids, stubMethodName);
|
|
34
|
+
await views.load(svc, loadArgs);
|
|
35
|
+
assert.isTrue(wasHit, `You did not load any remote cards. Next step is to add the following to your skill view's load():\n\nconst registrar = new CardRegistrar(...)\nconst cards = await registrar.fetch(...)\n\nAlso, make sure you create the new event that you'll emit when trying to fetch remote cards, something like 'my-skill.register-cards::v2020_02_02'\n\n`);
|
|
36
|
+
if (expectedTarget) {
|
|
37
|
+
assert.isEqualDeep(passedTarget, expectedTarget, 'The target you passed did not match!');
|
|
38
|
+
}
|
|
39
|
+
if (expectedPayload) {
|
|
40
|
+
assert.isEqualDeep(passedPayload, expectedPayload, 'The payload you passed did not match!');
|
|
41
|
+
}
|
|
42
|
+
let cards = [];
|
|
43
|
+
try {
|
|
44
|
+
cards = vcAssert.assertSkillViewRendersCards(svc, [vc1Id, vc2Id]);
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
assert.fail(`You didn't drop in the cards to your skill view! Make sure your vcIdsTransformer looks something like:
|
|
59
48
|
|
|
60
49
|
vcIdsTransformer: (payload) => {
|
|
61
50
|
return payload.vcIds
|
|
@@ -73,21 +62,20 @@ public render() {
|
|
|
73
62
|
}
|
|
74
63
|
}
|
|
75
64
|
|
|
76
|
-
The original error is: ${
|
|
65
|
+
The original error is: ${err.stack ?? err.message}
|
|
77
66
|
`);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
67
|
+
}
|
|
68
|
+
if (shouldInvoke) {
|
|
69
|
+
const { methodName, expectedParams } = shouldInvoke;
|
|
70
|
+
assert.isTrue(
|
|
71
|
+
//@ts-ignore
|
|
72
|
+
cards.filter((c) => c.wasHit).length === cards.length, `You gotta call cardVc.${methodName}(...) on all the cards you get back!`);
|
|
73
|
+
if (expectedParams) {
|
|
82
74
|
//@ts-ignore
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
//@ts-ignore
|
|
86
|
-
const passed = cards[0].passedParams;
|
|
87
|
-
assert.isEqualDeep(passed, expectedParams, `You didn't pass the expected params to ${methodName}!`);
|
|
88
|
-
}
|
|
75
|
+
const passed = cards[0].passedParams;
|
|
76
|
+
assert.isEqualDeep(passed, expectedParams, `You didn't pass the expected params to ${methodName}!`);
|
|
89
77
|
}
|
|
90
|
-
}
|
|
78
|
+
}
|
|
91
79
|
},
|
|
92
80
|
};
|
|
93
81
|
class ThrowingErrorCardVc extends AbstractViewController {
|