@sprucelabs/spruce-test-fixtures 59.0.93 → 59.1.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/build/__tests__/behavioral/views/Routing.test.d.ts +5 -0
- package/build/__tests__/behavioral/views/Routing.test.js +36 -0
- package/build/esm/__tests__/behavioral/views/Routing.test.d.ts +5 -0
- package/build/esm/__tests__/behavioral/views/Routing.test.js +42 -0
- package/build/esm/tests/routers/TestRouter.d.ts +12 -8
- package/build/esm/tests/routers/TestRouter.js +22 -7
- package/build/tests/routers/TestRouter.d.ts +12 -8
- package/build/tests/routers/TestRouter.js +22 -7
- package/package.json +4 -4
|
@@ -27,5 +27,10 @@ export default class RoutingTest extends AbstractSpruceFixtureTest {
|
|
|
27
27
|
protected static canSuppressBadControllerIdOnRedirect(): Promise<void>;
|
|
28
28
|
protected static shouldThrowWithBadSvcBecauseTestRouterIsReset(): Promise<void>;
|
|
29
29
|
protected static testRouterBuildsOptionsWithLocaleAndAuthorizer(): void;
|
|
30
|
+
protected static canSetPresentVc(): Promise<void>;
|
|
31
|
+
protected static canPullNamespaceFromPresentVc(id: any, namespace: string): Promise<void>;
|
|
32
|
+
protected static canSetNamespaceDirectly(): Promise<void>;
|
|
33
|
+
private static assertCurrentNamespace;
|
|
34
|
+
private static setPresentVc;
|
|
30
35
|
private static assertRedirects;
|
|
31
36
|
}
|
|
@@ -96,6 +96,31 @@ class RoutingTest extends AbstractSpruceFixtureTest_1.default {
|
|
|
96
96
|
test_utils_1.assert.isTrue(options.locale instanceof calendar_utils_1.LocaleImpl);
|
|
97
97
|
test_utils_1.assert.isTrue(options.authorizer instanceof FakeAuthorizer_1.default);
|
|
98
98
|
}
|
|
99
|
+
static async canSetPresentVc() {
|
|
100
|
+
const vc = this.views.Controller('heartwood.root', {});
|
|
101
|
+
this.setPresentVc(vc);
|
|
102
|
+
const actual = this.router.getPresentVc();
|
|
103
|
+
test_utils_1.assert.isEqual(actual, vc);
|
|
104
|
+
}
|
|
105
|
+
static async canPullNamespaceFromPresentVc(id, namespace) {
|
|
106
|
+
this.views.setController(id, Fake_svc_1.default);
|
|
107
|
+
const vc = this.views.Controller(id, {});
|
|
108
|
+
this.setPresentVc(vc);
|
|
109
|
+
this.assertCurrentNamespace(namespace);
|
|
110
|
+
}
|
|
111
|
+
static async canSetNamespaceDirectly() {
|
|
112
|
+
this.router.setNamespace('forms');
|
|
113
|
+
this.assertCurrentNamespace('forms');
|
|
114
|
+
this.router.setNamespace('heartwood');
|
|
115
|
+
this.assertCurrentNamespace('heartwood');
|
|
116
|
+
}
|
|
117
|
+
static assertCurrentNamespace(namespace) {
|
|
118
|
+
const actual = this.router.getNamespace();
|
|
119
|
+
test_utils_1.assert.isEqual(actual, namespace);
|
|
120
|
+
}
|
|
121
|
+
static setPresentVc(vc) {
|
|
122
|
+
this.router.setPresentVc(vc);
|
|
123
|
+
}
|
|
99
124
|
static async assertRedirects(action) {
|
|
100
125
|
return heartwood_view_controllers_1.vcAssert.assertActionRedirects({
|
|
101
126
|
action,
|
|
@@ -139,3 +164,14 @@ __decorate([
|
|
|
139
164
|
__decorate([
|
|
140
165
|
(0, test_utils_1.test)()
|
|
141
166
|
], RoutingTest, "testRouterBuildsOptionsWithLocaleAndAuthorizer", null);
|
|
167
|
+
__decorate([
|
|
168
|
+
(0, test_utils_1.test)()
|
|
169
|
+
], RoutingTest, "canSetPresentVc", null);
|
|
170
|
+
__decorate([
|
|
171
|
+
(0, test_utils_1.test)('can set namespace to heartwood', 'heartwood.root', 'heartwood'),
|
|
172
|
+
(0, test_utils_1.test)('can set namespace to forms', 'forms.root', 'forms'),
|
|
173
|
+
(0, test_utils_1.test)('can set namespace to forms.go', 'forms.go', 'forms')
|
|
174
|
+
], RoutingTest, "canPullNamespaceFromPresentVc", null);
|
|
175
|
+
__decorate([
|
|
176
|
+
(0, test_utils_1.test)()
|
|
177
|
+
], RoutingTest, "canSetNamespaceDirectly", null);
|
|
@@ -27,5 +27,10 @@ export default class RoutingTest extends AbstractSpruceFixtureTest {
|
|
|
27
27
|
protected static canSuppressBadControllerIdOnRedirect(): Promise<void>;
|
|
28
28
|
protected static shouldThrowWithBadSvcBecauseTestRouterIsReset(): Promise<void>;
|
|
29
29
|
protected static testRouterBuildsOptionsWithLocaleAndAuthorizer(): void;
|
|
30
|
+
protected static canSetPresentVc(): Promise<void>;
|
|
31
|
+
protected static canPullNamespaceFromPresentVc(id: any, namespace: string): Promise<void>;
|
|
32
|
+
protected static canSetNamespaceDirectly(): Promise<void>;
|
|
33
|
+
private static assertCurrentNamespace;
|
|
34
|
+
private static setPresentVc;
|
|
30
35
|
private static assertRedirects;
|
|
31
36
|
}
|
|
@@ -123,6 +123,37 @@ class RoutingTest extends AbstractSpruceFixtureTest {
|
|
|
123
123
|
assert.isTrue(options.locale instanceof LocaleImpl);
|
|
124
124
|
assert.isTrue(options.authorizer instanceof FakeAuthorizer);
|
|
125
125
|
}
|
|
126
|
+
static canSetPresentVc() {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const vc = this.views.Controller('heartwood.root', {});
|
|
129
|
+
this.setPresentVc(vc);
|
|
130
|
+
const actual = this.router.getPresentVc();
|
|
131
|
+
assert.isEqual(actual, vc);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
static canPullNamespaceFromPresentVc(id, namespace) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
this.views.setController(id, FakeSkillViewController);
|
|
137
|
+
const vc = this.views.Controller(id, {});
|
|
138
|
+
this.setPresentVc(vc);
|
|
139
|
+
this.assertCurrentNamespace(namespace);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
static canSetNamespaceDirectly() {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
this.router.setNamespace('forms');
|
|
145
|
+
this.assertCurrentNamespace('forms');
|
|
146
|
+
this.router.setNamespace('heartwood');
|
|
147
|
+
this.assertCurrentNamespace('heartwood');
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
static assertCurrentNamespace(namespace) {
|
|
151
|
+
const actual = this.router.getNamespace();
|
|
152
|
+
assert.isEqual(actual, namespace);
|
|
153
|
+
}
|
|
154
|
+
static setPresentVc(vc) {
|
|
155
|
+
this.router.setPresentVc(vc);
|
|
156
|
+
}
|
|
126
157
|
static assertRedirects(action) {
|
|
127
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
159
|
return vcAssert.assertActionRedirects({
|
|
@@ -168,3 +199,14 @@ __decorate([
|
|
|
168
199
|
__decorate([
|
|
169
200
|
test()
|
|
170
201
|
], RoutingTest, "testRouterBuildsOptionsWithLocaleAndAuthorizer", null);
|
|
202
|
+
__decorate([
|
|
203
|
+
test()
|
|
204
|
+
], RoutingTest, "canSetPresentVc", null);
|
|
205
|
+
__decorate([
|
|
206
|
+
test('can set namespace to heartwood', 'heartwood.root', 'heartwood'),
|
|
207
|
+
test('can set namespace to forms', 'forms.root', 'forms'),
|
|
208
|
+
test('can set namespace to forms.go', 'forms.go', 'forms')
|
|
209
|
+
], RoutingTest, "canPullNamespaceFromPresentVc", null);
|
|
210
|
+
__decorate([
|
|
211
|
+
test()
|
|
212
|
+
], RoutingTest, "canSetNamespaceDirectly", null);
|
|
@@ -3,14 +3,6 @@ import { Authorizer, Router, Scope, SkillViewController, SkillViewControllerArgs
|
|
|
3
3
|
import { AbstractEventEmitter } from '@sprucelabs/mercury-event-emitter';
|
|
4
4
|
import { MercuryEventEmitter } from '@sprucelabs/mercury-types';
|
|
5
5
|
import FakeThemeManager from '../../__tests__/support/FakeThemeManager';
|
|
6
|
-
declare const contract: {
|
|
7
|
-
eventSignatures: {
|
|
8
|
-
'did-redirect': {
|
|
9
|
-
emitPayloadSchema: import("@sprucelabs/calendar-utils").SpruceSchemas.SpruceTestFixtures.v2021_07_19.TestRouterEmitPayloadSchema;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
type Contract = typeof contract;
|
|
14
6
|
export default class TestRouter extends AbstractEventEmitter<Contract> implements Router, MercuryEventEmitter<Contract> {
|
|
15
7
|
private vcFactory;
|
|
16
8
|
private presentVc?;
|
|
@@ -22,6 +14,7 @@ export default class TestRouter extends AbstractEventEmitter<Contract> implement
|
|
|
22
14
|
private static shouldThrowWhenRedirectingToBadSvc;
|
|
23
15
|
private scope;
|
|
24
16
|
private locale;
|
|
17
|
+
private manuallySetNamespace?;
|
|
25
18
|
private readonly themes;
|
|
26
19
|
private authorizer;
|
|
27
20
|
private static authorizer;
|
|
@@ -30,6 +23,9 @@ export default class TestRouter extends AbstractEventEmitter<Contract> implement
|
|
|
30
23
|
static setShouldLoadDestinationVc(shouldLoad: boolean): void;
|
|
31
24
|
static getInstance(): TestRouter;
|
|
32
25
|
getThemes(): FakeThemeManager;
|
|
26
|
+
setPresentVc(vc: SkillViewController): void;
|
|
27
|
+
setNamespace(namespace: string): void;
|
|
28
|
+
getNamespace(): any;
|
|
33
29
|
static setup(options: {
|
|
34
30
|
vcFactory: ViewControllerFactory;
|
|
35
31
|
scope: Scope;
|
|
@@ -42,4 +38,12 @@ export default class TestRouter extends AbstractEventEmitter<Contract> implement
|
|
|
42
38
|
static reset(): void;
|
|
43
39
|
buildLoadOptions(args?: any): SkillViewControllerLoadOptions;
|
|
44
40
|
}
|
|
41
|
+
declare const contract: {
|
|
42
|
+
eventSignatures: {
|
|
43
|
+
'did-redirect': {
|
|
44
|
+
emitPayloadSchema: import("@sprucelabs/calendar-utils").SpruceSchemas.SpruceTestFixtures.v2021_07_19.TestRouterEmitPayloadSchema;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
type Contract = typeof contract;
|
|
45
49
|
export {};
|
|
@@ -12,13 +12,6 @@ import { AbstractEventEmitter } from '@sprucelabs/mercury-event-emitter';
|
|
|
12
12
|
import { buildEventContract, } from '@sprucelabs/mercury-types';
|
|
13
13
|
import testRouterEmitPayloadSchema from './../../.spruce/schemas/spruceTestFixtures/v2021_07_19/testRouterEmitPayload.schema.js';
|
|
14
14
|
import FakeThemeManager from '../../__tests__/support/FakeThemeManager.js';
|
|
15
|
-
const contract = buildEventContract({
|
|
16
|
-
eventSignatures: {
|
|
17
|
-
'did-redirect': {
|
|
18
|
-
emitPayloadSchema: testRouterEmitPayloadSchema,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
15
|
class TestRouter extends AbstractEventEmitter {
|
|
23
16
|
static setShouldThrowWhenRedirectingToBadSvc(shouldThrow) {
|
|
24
17
|
this.shouldThrowWhenRedirectingToBadSvc = shouldThrow;
|
|
@@ -52,6 +45,21 @@ class TestRouter extends AbstractEventEmitter {
|
|
|
52
45
|
getThemes() {
|
|
53
46
|
return this.themes;
|
|
54
47
|
}
|
|
48
|
+
setPresentVc(vc) {
|
|
49
|
+
this.presentVc = vc;
|
|
50
|
+
}
|
|
51
|
+
setNamespace(namespace) {
|
|
52
|
+
this.manuallySetNamespace = namespace;
|
|
53
|
+
}
|
|
54
|
+
getNamespace() {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
if (this.manuallySetNamespace) {
|
|
57
|
+
return this.manuallySetNamespace;
|
|
58
|
+
}
|
|
59
|
+
//@ts-ignore
|
|
60
|
+
const id = (_b = (_a = this.presentVc) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : 'heartwood.root';
|
|
61
|
+
return id.split('.')[0];
|
|
62
|
+
}
|
|
55
63
|
static setup(options) {
|
|
56
64
|
this.vcFactory = options.vcFactory;
|
|
57
65
|
this.scope = options.scope;
|
|
@@ -104,3 +112,10 @@ class TestRouter extends AbstractEventEmitter {
|
|
|
104
112
|
TestRouter.shouldLoadDestinationVc = false;
|
|
105
113
|
TestRouter.shouldThrowWhenRedirectingToBadSvc = true;
|
|
106
114
|
export default TestRouter;
|
|
115
|
+
const contract = buildEventContract({
|
|
116
|
+
eventSignatures: {
|
|
117
|
+
'did-redirect': {
|
|
118
|
+
emitPayloadSchema: testRouterEmitPayloadSchema,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
});
|
|
@@ -3,14 +3,6 @@ import { Authorizer, Router, Scope, SkillViewController, SkillViewControllerArgs
|
|
|
3
3
|
import { AbstractEventEmitter } from '@sprucelabs/mercury-event-emitter';
|
|
4
4
|
import { MercuryEventEmitter } from '@sprucelabs/mercury-types';
|
|
5
5
|
import FakeThemeManager from '../../__tests__/support/FakeThemeManager';
|
|
6
|
-
declare const contract: {
|
|
7
|
-
eventSignatures: {
|
|
8
|
-
'did-redirect': {
|
|
9
|
-
emitPayloadSchema: import("@sprucelabs/calendar-utils").SpruceSchemas.SpruceTestFixtures.v2021_07_19.TestRouterEmitPayloadSchema;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
type Contract = typeof contract;
|
|
14
6
|
export default class TestRouter extends AbstractEventEmitter<Contract> implements Router, MercuryEventEmitter<Contract> {
|
|
15
7
|
private vcFactory;
|
|
16
8
|
private presentVc?;
|
|
@@ -22,6 +14,7 @@ export default class TestRouter extends AbstractEventEmitter<Contract> implement
|
|
|
22
14
|
private static shouldThrowWhenRedirectingToBadSvc;
|
|
23
15
|
private scope;
|
|
24
16
|
private locale;
|
|
17
|
+
private manuallySetNamespace?;
|
|
25
18
|
private readonly themes;
|
|
26
19
|
private authorizer;
|
|
27
20
|
private static authorizer;
|
|
@@ -30,6 +23,9 @@ export default class TestRouter extends AbstractEventEmitter<Contract> implement
|
|
|
30
23
|
static setShouldLoadDestinationVc(shouldLoad: boolean): void;
|
|
31
24
|
static getInstance(): TestRouter;
|
|
32
25
|
getThemes(): FakeThemeManager;
|
|
26
|
+
setPresentVc(vc: SkillViewController): void;
|
|
27
|
+
setNamespace(namespace: string): void;
|
|
28
|
+
getNamespace(): any;
|
|
33
29
|
static setup(options: {
|
|
34
30
|
vcFactory: ViewControllerFactory;
|
|
35
31
|
scope: Scope;
|
|
@@ -42,4 +38,12 @@ export default class TestRouter extends AbstractEventEmitter<Contract> implement
|
|
|
42
38
|
static reset(): void;
|
|
43
39
|
buildLoadOptions(args?: any): SkillViewControllerLoadOptions;
|
|
44
40
|
}
|
|
41
|
+
declare const contract: {
|
|
42
|
+
eventSignatures: {
|
|
43
|
+
'did-redirect': {
|
|
44
|
+
emitPayloadSchema: import("@sprucelabs/calendar-utils").SpruceSchemas.SpruceTestFixtures.v2021_07_19.TestRouterEmitPayloadSchema;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
type Contract = typeof contract;
|
|
45
49
|
export {};
|
|
@@ -8,13 +8,6 @@ const mercury_event_emitter_1 = require("@sprucelabs/mercury-event-emitter");
|
|
|
8
8
|
const mercury_types_1 = require("@sprucelabs/mercury-types");
|
|
9
9
|
const testRouterEmitPayload_schema_1 = __importDefault(require("./../../.spruce/schemas/spruceTestFixtures/v2021_07_19/testRouterEmitPayload.schema"));
|
|
10
10
|
const FakeThemeManager_1 = __importDefault(require("../../__tests__/support/FakeThemeManager"));
|
|
11
|
-
const contract = (0, mercury_types_1.buildEventContract)({
|
|
12
|
-
eventSignatures: {
|
|
13
|
-
'did-redirect': {
|
|
14
|
-
emitPayloadSchema: testRouterEmitPayload_schema_1.default,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
11
|
class TestRouter extends mercury_event_emitter_1.AbstractEventEmitter {
|
|
19
12
|
static setShouldThrowWhenRedirectingToBadSvc(shouldThrow) {
|
|
20
13
|
this.shouldThrowWhenRedirectingToBadSvc = shouldThrow;
|
|
@@ -48,6 +41,21 @@ class TestRouter extends mercury_event_emitter_1.AbstractEventEmitter {
|
|
|
48
41
|
getThemes() {
|
|
49
42
|
return this.themes;
|
|
50
43
|
}
|
|
44
|
+
setPresentVc(vc) {
|
|
45
|
+
this.presentVc = vc;
|
|
46
|
+
}
|
|
47
|
+
setNamespace(namespace) {
|
|
48
|
+
this.manuallySetNamespace = namespace;
|
|
49
|
+
}
|
|
50
|
+
getNamespace() {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
if (this.manuallySetNamespace) {
|
|
53
|
+
return this.manuallySetNamespace;
|
|
54
|
+
}
|
|
55
|
+
//@ts-ignore
|
|
56
|
+
const id = (_b = (_a = this.presentVc) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : 'heartwood.root';
|
|
57
|
+
return id.split('.')[0];
|
|
58
|
+
}
|
|
51
59
|
static setup(options) {
|
|
52
60
|
this.vcFactory = options.vcFactory;
|
|
53
61
|
this.scope = options.scope;
|
|
@@ -96,3 +104,10 @@ class TestRouter extends mercury_event_emitter_1.AbstractEventEmitter {
|
|
|
96
104
|
TestRouter.shouldLoadDestinationVc = false;
|
|
97
105
|
TestRouter.shouldThrowWhenRedirectingToBadSvc = true;
|
|
98
106
|
exports.default = TestRouter;
|
|
107
|
+
const contract = (0, mercury_types_1.buildEventContract)({
|
|
108
|
+
eventSignatures: {
|
|
109
|
+
'did-redirect': {
|
|
110
|
+
emitPayloadSchema: testRouterEmitPayload_schema_1.default,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
});
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@sprucelabs/spruce-test-fixtures"
|
|
14
14
|
]
|
|
15
15
|
},
|
|
16
|
-
"version": "59.0
|
|
16
|
+
"version": "59.1.0",
|
|
17
17
|
"files": [
|
|
18
18
|
"build/**/*",
|
|
19
19
|
"!build/__tests__",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@sprucelabs/data-stores": "^24.0.38",
|
|
66
66
|
"@sprucelabs/error": "^5.1.11",
|
|
67
|
-
"@sprucelabs/heartwood-view-controllers": "^105.0
|
|
67
|
+
"@sprucelabs/heartwood-view-controllers": "^105.1.0",
|
|
68
68
|
"@sprucelabs/mercury-client": "^40.1.81",
|
|
69
69
|
"@sprucelabs/mercury-core-events": "^21.2.3",
|
|
70
70
|
"@sprucelabs/mercury-event-emitter": "^40.1.81",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@sprucelabs/spruce-core-schemas": "^38.1.52",
|
|
73
73
|
"@sprucelabs/spruce-event-utils": "^37.0.68",
|
|
74
74
|
"@sprucelabs/spruce-permission-utils": "^5.0.133",
|
|
75
|
-
"@sprucelabs/spruce-skill-booter": "^59.0
|
|
75
|
+
"@sprucelabs/spruce-skill-booter": "^59.1.0",
|
|
76
76
|
"@sprucelabs/spruce-skill-utils": "^29.1.19",
|
|
77
77
|
"@sprucelabs/test-utils": "^3.4.75",
|
|
78
78
|
"dotenv": "^16.3.1",
|
|
@@ -132,5 +132,5 @@
|
|
|
132
132
|
]
|
|
133
133
|
]
|
|
134
134
|
},
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "4a4f283a8d7fd8edd479043d9bb020114e57dc20"
|
|
136
136
|
}
|