@sprucelabs/spruce-test-fixtures 49.0.39 → 49.0.42
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/CanUseStoresSetupInBeforeEach.test.js +5 -5
- package/build/__tests__/behavioral/DatabaseFixture.test.d.ts +1 -1
- package/build/__tests__/behavioral/DatabaseFixture.test.js +7 -7
- package/build/__tests__/behavioral/DbResetsAsExpected.test.js +4 -4
- package/build/__tests__/behavioral/DecoratoringEmitToPassThroughProxy.test.js +18 -18
- package/build/__tests__/behavioral/DelaysConnectWhenOnlyUsingLoginDecorator.test.js +3 -3
- package/build/__tests__/behavioral/DisablingSchemaValidationOnTest.test.js +5 -5
- package/build/__tests__/behavioral/DoesntResetAccountIfOnlySeedingLocally.test.js +9 -9
- package/build/__tests__/behavioral/FakingEventResponses.test.js +15 -15
- package/build/__tests__/behavioral/FixtureFactory.test.d.ts +1 -1
- package/build/__tests__/behavioral/FixtureFactory.test.js +14 -14
- package/build/__tests__/behavioral/LocationFixture.test.js +17 -17
- package/build/__tests__/behavioral/LoginDecoratorHandlingProxiesForMe.test.js +11 -11
- package/build/__tests__/behavioral/MakingSureLocalEventsAreHandledLocally.test.js +3 -3
- package/build/__tests__/behavioral/MercuryFixture.test.js +28 -28
- package/build/__tests__/behavioral/OrganizationFixture.test.js +50 -50
- package/build/__tests__/behavioral/PatchingConsoleErrorToErrorStream.test.js +3 -3
- package/build/__tests__/behavioral/PersonFixture.test.d.ts +1 -1
- package/build/__tests__/behavioral/PersonFixture.test.js +37 -37
- package/build/__tests__/behavioral/PhoneNumberIncrementor.test.js +22 -22
- package/build/__tests__/behavioral/ResettingAccountLocationsInBeforeAll.test.js +5 -5
- package/build/__tests__/behavioral/ResettingAccountOrgsInAfterAll.test.js +3 -3
- package/build/__tests__/behavioral/ResettingAccountOrgsInBeforeAll.test.js +5 -5
- package/build/__tests__/behavioral/ResettingFixtureFieldsBeforeEach.test.js +9 -9
- package/build/__tests__/behavioral/ResettingLocalEventListeningBeforeSeeding.test.js +4 -4
- package/build/__tests__/behavioral/RetainsContractWhenLoggingInUsingDecotorator.test.js +2 -2
- package/build/__tests__/behavioral/RoleFixture.test.js +15 -15
- package/build/__tests__/behavioral/SeedingData.test.js +43 -43
- package/build/__tests__/behavioral/SkillFixture.test.js +22 -22
- package/build/__tests__/behavioral/StoreFixture.test.d.ts +1 -1
- package/build/__tests__/behavioral/StoreFixture.test.js +20 -20
- package/build/__tests__/behavioral/faking/AuthenticatingAsAPerson.test.js +11 -11
- package/build/__tests__/behavioral/faking/FakeDecorator.test.js +74 -74
- package/build/__tests__/behavioral/faking/FakeDecoratorSetsPerson.test.js +3 -3
- package/build/__tests__/behavioral/faking/FakeDecoratorWhoAmI.test.js +3 -3
- package/build/__tests__/behavioral/faking/FakeThemeManager.test.d.ts +1 -1
- package/build/__tests__/behavioral/faking/FakeThemeManager.test.js +8 -8
- package/build/__tests__/behavioral/faking/FakingAddingPeopleToALocation.test.js +6 -6
- package/build/__tests__/behavioral/faking/FakingAddingPeopleToAnOrg.test.js +15 -15
- package/build/__tests__/behavioral/faking/FakingAuthenticator.test.js +5 -5
- package/build/__tests__/behavioral/faking/FakingInBeforeEach.test.js +5 -5
- package/build/__tests__/behavioral/faking/FakingRoleEvents.test.js +19 -19
- package/build/__tests__/behavioral/faking/FakingSkillEvents.test.js +41 -41
- package/build/__tests__/behavioral/faking/UpdatePerson.test.js +5 -5
- package/build/__tests__/behavioral/faking/UsingFakeDecorators.test.js +60 -60
- package/build/__tests__/behavioral/faking/UsingFakesOnIncompatibleClass.test.d.ts +1 -1
- package/build/__tests__/behavioral/faking/UsingFakesOnIncompatibleClass.test.js +4 -4
- package/build/__tests__/behavioral/faking/WhoAmI.test.js +12 -12
- package/build/__tests__/behavioral/maps/SpyingMapUtil.test.js +17 -17
- package/build/__tests__/behavioral/seeding/UsingDecorators.test.js +54 -54
- package/build/__tests__/behavioral/seeding/UsingDecoratorsToInstallSkills.test.js +16 -16
- package/build/__tests__/behavioral/views/CheckingPermissions.test.js +30 -30
- package/build/__tests__/behavioral/views/FakingSkillViewControllers.test.js +8 -8
- package/build/__tests__/behavioral/views/Routing.test.js +30 -30
- package/build/__tests__/behavioral/views/TestingScope.test.js +10 -10
- package/build/__tests__/behavioral/views/ViewFixture.test.js +107 -107
- package/build/__tests__/behavioral/views/WorkingWithTimezones.test.js +10 -10
- package/build/__tests__/support/AbstractFakeDecoratorTest.js +4 -4
- package/build/esm/__tests__/behavioral/CanUseStoresSetupInBeforeEach.test.js +1 -1
- package/build/esm/__tests__/behavioral/DatabaseFixture.test.d.ts +1 -1
- package/build/esm/__tests__/behavioral/DatabaseFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/DbResetsAsExpected.test.js +1 -1
- package/build/esm/__tests__/behavioral/DecoratoringEmitToPassThroughProxy.test.js +1 -1
- package/build/esm/__tests__/behavioral/DelaysConnectWhenOnlyUsingLoginDecorator.test.js +1 -1
- package/build/esm/__tests__/behavioral/DisablingSchemaValidationOnTest.test.js +1 -1
- package/build/esm/__tests__/behavioral/DoesntResetAccountIfOnlySeedingLocally.test.js +1 -1
- package/build/esm/__tests__/behavioral/FakingEventResponses.test.js +1 -1
- package/build/esm/__tests__/behavioral/FixtureFactory.test.d.ts +1 -1
- package/build/esm/__tests__/behavioral/FixtureFactory.test.js +1 -1
- package/build/esm/__tests__/behavioral/LocationFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/LoginDecoratorHandlingProxiesForMe.test.js +1 -1
- package/build/esm/__tests__/behavioral/MakingSureLocalEventsAreHandledLocally.test.js +1 -1
- package/build/esm/__tests__/behavioral/MercuryFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/OrganizationFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/PatchingConsoleErrorToErrorStream.test.js +1 -1
- package/build/esm/__tests__/behavioral/PersonFixture.test.d.ts +1 -1
- package/build/esm/__tests__/behavioral/PersonFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/PhoneNumberIncrementor.test.js +1 -1
- package/build/esm/__tests__/behavioral/ResettingAccountLocationsInBeforeAll.test.js +1 -1
- package/build/esm/__tests__/behavioral/ResettingAccountOrgsInAfterAll.test.js +1 -1
- package/build/esm/__tests__/behavioral/ResettingAccountOrgsInBeforeAll.test.js +1 -1
- package/build/esm/__tests__/behavioral/ResettingFixtureFieldsBeforeEach.test.js +1 -1
- package/build/esm/__tests__/behavioral/ResettingLocalEventListeningBeforeSeeding.test.js +1 -1
- package/build/esm/__tests__/behavioral/RetainsContractWhenLoggingInUsingDecotorator.test.js +1 -1
- package/build/esm/__tests__/behavioral/RoleFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/SeedingData.test.js +1 -1
- package/build/esm/__tests__/behavioral/SkillFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/StoreFixture.test.d.ts +1 -1
- package/build/esm/__tests__/behavioral/StoreFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/AuthenticatingAsAPerson.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakeDecorator.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakeDecoratorSetsPerson.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakeDecoratorWhoAmI.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakeThemeManager.test.d.ts +1 -1
- package/build/esm/__tests__/behavioral/faking/FakeThemeManager.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakingAddingPeopleToALocation.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakingAddingPeopleToAnOrg.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakingAuthenticator.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakingInBeforeEach.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakingRoleEvents.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/FakingSkillEvents.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/UpdatePerson.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/UsingFakeDecorators.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/UsingFakesOnIncompatibleClass.test.d.ts +1 -1
- package/build/esm/__tests__/behavioral/faking/UsingFakesOnIncompatibleClass.test.js +1 -1
- package/build/esm/__tests__/behavioral/faking/WhoAmI.test.js +1 -1
- package/build/esm/__tests__/behavioral/maps/SpyingMapUtil.test.js +1 -1
- package/build/esm/__tests__/behavioral/seeding/UsingDecorators.test.js +1 -1
- package/build/esm/__tests__/behavioral/seeding/UsingDecoratorsToInstallSkills.test.js +1 -1
- package/build/esm/__tests__/behavioral/views/CheckingPermissions.test.js +1 -1
- package/build/esm/__tests__/behavioral/views/FakingSkillViewControllers.test.js +1 -1
- package/build/esm/__tests__/behavioral/views/Routing.test.js +1 -1
- package/build/esm/__tests__/behavioral/views/TestingScope.test.js +1 -1
- package/build/esm/__tests__/behavioral/views/ViewFixture.test.js +1 -1
- package/build/esm/__tests__/behavioral/views/WorkingWithTimezones.test.js +1 -1
- package/build/esm/__tests__/support/AbstractFakeDecoratorTest.js +1 -1
- package/build/esm/tests/AbstractSpruceFixtureTest.js +1 -1
- package/build/esm/tests/SpyAuthorizer.js +1 -1
- package/build/esm/tests/decorators/fake.js +1 -1
- package/build/esm/tests/decorators/install.js +1 -1
- package/build/esm/tests/decorators/login.js +1 -1
- package/build/esm/tests/decorators/seed.js +1 -1
- package/build/esm/tests/fixtures/LocationFixture.js +1 -1
- package/build/esm/tests/fixtures/RoleFixture.js +1 -1
- package/build/esm/tests/fixtures/SeedFixture.js +1 -1
- package/build/tests/AbstractSpruceFixtureTest.js +3 -3
- package/build/tests/SpyAuthorizer.js +3 -3
- package/build/tests/decorators/fake.js +20 -20
- package/build/tests/decorators/install.js +3 -3
- package/build/tests/decorators/login.js +4 -4
- package/build/tests/decorators/seed.js +2 -2
- package/build/tests/fixtures/LocationFixture.js +3 -3
- package/build/tests/fixtures/RoleFixture.js +2 -2
- package/build/tests/fixtures/SeedFixture.js +2 -2
- package/package.json +5 -5
|
@@ -9,33 +9,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const test_1 = require("@sprucelabs/test");
|
|
13
12
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
13
|
+
const test_utils_2 = require("@sprucelabs/test-utils");
|
|
14
14
|
const AbstractSpruceFixtureTest_1 = __importDefault(require("../../../tests/AbstractSpruceFixtureTest"));
|
|
15
15
|
const ViewFixture_1 = __importDefault(require("../../../tests/fixtures/ViewFixture"));
|
|
16
16
|
const SpyAuthorizer_1 = __importDefault(require("../../../tests/SpyAuthorizer"));
|
|
17
17
|
class CheckingPermissionsTest extends AbstractSpruceFixtureTest_1.default {
|
|
18
18
|
static async beforeEach() {
|
|
19
19
|
await super.beforeEach();
|
|
20
|
-
this.contractId = (0,
|
|
20
|
+
this.contractId = (0, test_utils_2.generateId)();
|
|
21
21
|
}
|
|
22
22
|
static async canCreateCheckingPermissions() {
|
|
23
23
|
const instance = CheckingPermissionsTest.getInstance();
|
|
24
|
-
|
|
24
|
+
test_utils_1.assert.isTrue(instance instanceof SpyAuthorizer_1.default);
|
|
25
25
|
}
|
|
26
26
|
static async sharesInstances() {
|
|
27
|
-
|
|
27
|
+
test_utils_1.assert.isEqual(this.getInstance(), this.getInstance());
|
|
28
28
|
}
|
|
29
29
|
static async viewsFixtureResetsInstance() {
|
|
30
30
|
const instance = this.getInstance();
|
|
31
31
|
await ViewFixture_1.default.beforeEach();
|
|
32
|
-
|
|
32
|
+
test_utils_1.assert.isNotEqual(this.getInstance(), instance);
|
|
33
33
|
}
|
|
34
34
|
static async throwsWhenMissingOnCan() {
|
|
35
|
-
const err = await
|
|
35
|
+
const err = await test_utils_1.assert.doesThrowAsync(() =>
|
|
36
36
|
//@ts-ignore
|
|
37
37
|
this.getInstance().can());
|
|
38
|
-
|
|
38
|
+
test_utils_2.errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
39
39
|
parameters: ['contractId', 'permissionIds'],
|
|
40
40
|
});
|
|
41
41
|
}
|
|
@@ -67,7 +67,7 @@ class CheckingPermissionsTest extends AbstractSpruceFixtureTest_1.default {
|
|
|
67
67
|
permissionIds.forEach((id) => ((expected[id] = can), faked.push({ id, can })));
|
|
68
68
|
this.fakePermissions(faked);
|
|
69
69
|
const results = await this.can(permissionIds);
|
|
70
|
-
|
|
70
|
+
test_utils_1.assert.isEqualDeep(results, expected);
|
|
71
71
|
}
|
|
72
72
|
static async fixtureAndLoadOptionsShareAuthorizer() {
|
|
73
73
|
this.views = this.Fixture('view', {
|
|
@@ -75,13 +75,13 @@ class CheckingPermissionsTest extends AbstractSpruceFixtureTest_1.default {
|
|
|
75
75
|
});
|
|
76
76
|
const auth = this.views.getAuthorizer();
|
|
77
77
|
const router = this.views.getRouter();
|
|
78
|
-
|
|
78
|
+
test_utils_1.assert.isEqual(auth, router.buildLoadOptions().authorizer);
|
|
79
79
|
}
|
|
80
80
|
static async authorizerClobbersMatchingContracts() {
|
|
81
81
|
this.fakePermissions([{ id: 'test', can: true }]);
|
|
82
82
|
this.fakePermissions([{ id: 'test', can: false }]);
|
|
83
83
|
const perms = await this.can(['test']);
|
|
84
|
-
|
|
84
|
+
test_utils_1.assert.isFalse(perms['test']);
|
|
85
85
|
}
|
|
86
86
|
static async canHandleMulplePermissionsWithDifferentContracts() {
|
|
87
87
|
const firstId = this.contractId;
|
|
@@ -90,16 +90,16 @@ class CheckingPermissionsTest extends AbstractSpruceFixtureTest_1.default {
|
|
|
90
90
|
this.fakePermissions([{ id: 'test', can: false }]);
|
|
91
91
|
this.contractId = firstId;
|
|
92
92
|
const perms = await this.can(['test']);
|
|
93
|
-
|
|
93
|
+
test_utils_1.assert.isTrue(perms['test']);
|
|
94
94
|
}
|
|
95
95
|
static async assertPermNotFound(checkIds, id) {
|
|
96
|
-
await
|
|
96
|
+
await test_utils_1.assert.doesThrowAsync(() => this.can(checkIds), id);
|
|
97
97
|
}
|
|
98
98
|
static changeContractId() {
|
|
99
|
-
this.contractId = (0,
|
|
99
|
+
this.contractId = (0, test_utils_2.generateId)();
|
|
100
100
|
}
|
|
101
101
|
static async assertThrowsFakeError() {
|
|
102
|
-
await
|
|
102
|
+
await test_utils_1.assert.doesThrowAsync(() => this.can(['test']), `Contract by the id '${this.contractId}'`);
|
|
103
103
|
}
|
|
104
104
|
static fakePermissions(faked) {
|
|
105
105
|
this.getInstance().fakePermissions({
|
|
@@ -118,45 +118,45 @@ class CheckingPermissionsTest extends AbstractSpruceFixtureTest_1.default {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
__decorate([
|
|
121
|
-
(0,
|
|
121
|
+
(0, test_utils_1.test)()
|
|
122
122
|
], CheckingPermissionsTest, "canCreateCheckingPermissions", null);
|
|
123
123
|
__decorate([
|
|
124
|
-
(0,
|
|
124
|
+
(0, test_utils_1.test)()
|
|
125
125
|
], CheckingPermissionsTest, "sharesInstances", null);
|
|
126
126
|
__decorate([
|
|
127
|
-
(0,
|
|
127
|
+
(0, test_utils_1.test)()
|
|
128
128
|
], CheckingPermissionsTest, "viewsFixtureResetsInstance", null);
|
|
129
129
|
__decorate([
|
|
130
|
-
(0,
|
|
130
|
+
(0, test_utils_1.test)()
|
|
131
131
|
], CheckingPermissionsTest, "throwsWhenMissingOnCan", null);
|
|
132
132
|
__decorate([
|
|
133
|
-
(0,
|
|
133
|
+
(0, test_utils_1.test)()
|
|
134
134
|
], CheckingPermissionsTest, "throwsWhenNotSettingResponse", null);
|
|
135
135
|
__decorate([
|
|
136
|
-
(0,
|
|
136
|
+
(0, test_utils_1.test)()
|
|
137
137
|
], CheckingPermissionsTest, "throwsWhenContractIdNotFaked", null);
|
|
138
138
|
__decorate([
|
|
139
|
-
(0,
|
|
139
|
+
(0, test_utils_1.test)()
|
|
140
140
|
], CheckingPermissionsTest, "doesNotThrowWhenMatchingSecondContractId", null);
|
|
141
141
|
__decorate([
|
|
142
|
-
(0,
|
|
142
|
+
(0, test_utils_1.test)()
|
|
143
143
|
], CheckingPermissionsTest, "throwsWhenNotFindingPermissionId", null);
|
|
144
144
|
__decorate([
|
|
145
|
-
(0,
|
|
145
|
+
(0, test_utils_1.test)()
|
|
146
146
|
], CheckingPermissionsTest, "throwsWhenFindingLaterMissingPermId", null);
|
|
147
147
|
__decorate([
|
|
148
|
-
(0,
|
|
149
|
-
(0,
|
|
150
|
-
(0,
|
|
151
|
-
(0,
|
|
148
|
+
(0, test_utils_1.test)('returns false on can 1', ['first', 'second', 'third'], false),
|
|
149
|
+
(0, test_utils_1.test)('returns false on can 2', ['third', 'fourth'], false),
|
|
150
|
+
(0, test_utils_1.test)('returns false on can 3', ['first', 'second', 'third'], true),
|
|
151
|
+
(0, test_utils_1.test)('returns false on can 4', ['third', 'fourth'], true)
|
|
152
152
|
], CheckingPermissionsTest, "returnsFakedResponses", null);
|
|
153
153
|
__decorate([
|
|
154
|
-
(0,
|
|
154
|
+
(0, test_utils_1.test)()
|
|
155
155
|
], CheckingPermissionsTest, "fixtureAndLoadOptionsShareAuthorizer", null);
|
|
156
156
|
__decorate([
|
|
157
|
-
(0,
|
|
157
|
+
(0, test_utils_1.test)()
|
|
158
158
|
], CheckingPermissionsTest, "authorizerClobbersMatchingContracts", null);
|
|
159
159
|
__decorate([
|
|
160
|
-
(0,
|
|
160
|
+
(0, test_utils_1.test)()
|
|
161
161
|
], CheckingPermissionsTest, "canHandleMulplePermissionsWithDifferentContracts", null);
|
|
162
162
|
exports.default = CheckingPermissionsTest;
|
|
@@ -11,7 +11,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
13
13
|
const schema_1 = require("@sprucelabs/schema");
|
|
14
|
-
const
|
|
14
|
+
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
15
15
|
const AbstractSpruceFixtureTest_1 = __importDefault(require("../../../tests/AbstractSpruceFixtureTest"));
|
|
16
16
|
const Fake_svc_1 = __importDefault(require("../../../tests/Fake.svc"));
|
|
17
17
|
class FakingSkillViewControllersTest extends AbstractSpruceFixtureTest_1.default {
|
|
@@ -30,26 +30,26 @@ class FakingSkillViewControllersTest extends AbstractSpruceFixtureTest_1.default
|
|
|
30
30
|
}
|
|
31
31
|
static async passesThroughConstructorAptions(options) {
|
|
32
32
|
const vc = this.viewFixture.Controller('fake', options);
|
|
33
|
-
|
|
33
|
+
test_utils_1.assert.doesInclude(vc.constructorOptions, options);
|
|
34
34
|
}
|
|
35
35
|
static async passesThroughLoadArgs(args) {
|
|
36
36
|
const vc = this.viewFixture.Controller('fake', {});
|
|
37
37
|
await this.viewFixture.load(vc, args);
|
|
38
|
-
|
|
38
|
+
test_utils_1.assert.isEqualDeep(vc.args, args);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
FakingSkillViewControllersTest.controllerMap = {
|
|
42
42
|
fake: Fake_svc_1.default,
|
|
43
43
|
};
|
|
44
44
|
__decorate([
|
|
45
|
-
(0,
|
|
45
|
+
(0, test_utils_1.test)()
|
|
46
46
|
], FakingSkillViewControllersTest, "canRenderkFakeSkillViewController", null);
|
|
47
47
|
__decorate([
|
|
48
|
-
(0,
|
|
49
|
-
(0,
|
|
48
|
+
(0, test_utils_1.test)('passed constructor options 1', { hello: 'world' }),
|
|
49
|
+
(0, test_utils_1.test)('passed constructor options 2', { taco: 'bell' })
|
|
50
50
|
], FakingSkillViewControllersTest, "passesThroughConstructorAptions", null);
|
|
51
51
|
__decorate([
|
|
52
|
-
(0,
|
|
53
|
-
(0,
|
|
52
|
+
(0, test_utils_1.test)('passes args 1', { hello: 'world' }),
|
|
53
|
+
(0, test_utils_1.test)('passes args 2', { cheesey: 'burrito' })
|
|
54
54
|
], FakingSkillViewControllersTest, "passesThroughLoadArgs", null);
|
|
55
55
|
exports.default = FakingSkillViewControllersTest;
|
|
@@ -13,8 +13,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
const calendar_utils_1 = require("@sprucelabs/calendar-utils");
|
|
14
14
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
15
15
|
const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
|
|
16
|
-
const test_1 = require("@sprucelabs/test");
|
|
17
16
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
17
|
+
const test_utils_2 = require("@sprucelabs/test-utils");
|
|
18
18
|
const AbstractSpruceFixtureTest_1 = __importDefault(require("../../../tests/AbstractSpruceFixtureTest"));
|
|
19
19
|
const Fake_svc_1 = __importDefault(require("../../../tests/Fake.svc"));
|
|
20
20
|
const TestRouter_1 = __importDefault(require("../../../tests/routers/TestRouter"));
|
|
@@ -29,33 +29,33 @@ class RoutingTest extends AbstractSpruceFixtureTest_1.default {
|
|
|
29
29
|
this.factory = fixture.getFactory();
|
|
30
30
|
}
|
|
31
31
|
static async throwsWithBadDestination() {
|
|
32
|
-
const err = await
|
|
32
|
+
const err = await test_utils_1.assert.doesThrowAsync(() =>
|
|
33
33
|
//@ts-ignore
|
|
34
34
|
this.assertRedirects(() => this.router.redirect('waka.waka')));
|
|
35
|
-
|
|
35
|
+
test_utils_2.errorAssert.assertError(err, 'INVALID_VIEW_CONTROLLER_NAME', {
|
|
36
36
|
name: 'waka.waka',
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
static async getPresentVcIsEmptyToStart() {
|
|
40
|
-
|
|
40
|
+
test_utils_1.assert.isFalsy(this.router.getPresentVc());
|
|
41
41
|
}
|
|
42
42
|
static async canRedirectToGoodSvcWithoutNamespace(id, Vc) {
|
|
43
43
|
await this.assertRedirects(() => this.router.redirect(id, {}));
|
|
44
44
|
const vc = this.router.getPresentVc();
|
|
45
|
-
|
|
45
|
+
test_utils_1.assert.isTrue(vc instanceof Vc);
|
|
46
46
|
}
|
|
47
47
|
static async redirectTriggersLoadWithExpectedItems(args) {
|
|
48
48
|
TestRouter_1.default.setShouldLoadDestinationVc(false);
|
|
49
49
|
//@ts-ignore
|
|
50
50
|
const vc = await this.assertRedirects(() => this.router.redirect('spruceTestFixtures.spy', args));
|
|
51
51
|
const lastLoad = vc.loads.pop();
|
|
52
|
-
|
|
52
|
+
test_utils_1.assert.isFalsy(lastLoad);
|
|
53
53
|
}
|
|
54
54
|
static async redirectByDefaultDoesNotLoadWithExpectedItems(args) {
|
|
55
55
|
//@ts-ignore
|
|
56
56
|
const vc = await this.assertRedirects(() => this.router.redirect('spruceTestFixtures.spy', args));
|
|
57
57
|
const lastLoad = vc.loads.pop();
|
|
58
|
-
|
|
58
|
+
test_utils_1.assert.isFalsy(lastLoad);
|
|
59
59
|
}
|
|
60
60
|
static async canHookIntoRedirectEvents(expectedArgs) {
|
|
61
61
|
let wasHit = false;
|
|
@@ -69,15 +69,15 @@ class RoutingTest extends AbstractSpruceFixtureTest_1.default {
|
|
|
69
69
|
passedArgs = args;
|
|
70
70
|
});
|
|
71
71
|
await this.assertRedirects(() => this.router.redirect('spruceTestFixtures.book', expectedArgs));
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
test_utils_1.assert.isTrue(wasHit);
|
|
73
|
+
test_utils_1.assert.isEqual(passedId, 'spruceTestFixtures.book');
|
|
74
|
+
test_utils_1.assert.isTruthy(passedVc);
|
|
75
|
+
test_utils_1.assert.isTrue(passedVc instanceof Book_svc_1.default);
|
|
76
|
+
test_utils_1.assert.isEqualDeep(passedArgs, expectedArgs);
|
|
77
77
|
}
|
|
78
78
|
static async canFakeRedirectToHeartwoodRoot() {
|
|
79
79
|
const svc = await this.assertRedirects(() => this.router.redirect('heartwood.root'));
|
|
80
|
-
|
|
80
|
+
test_utils_1.assert.isTrue(svc instanceof Fake_svc_1.default);
|
|
81
81
|
}
|
|
82
82
|
static async canSuppressBadControllerIdOnRedirect() {
|
|
83
83
|
TestRouter_1.default.setShouldThrowWhenRedirectingToBadSvc(false);
|
|
@@ -87,14 +87,14 @@ class RoutingTest extends AbstractSpruceFixtureTest_1.default {
|
|
|
87
87
|
await this.assertRedirects(() => this.router.redirect(id));
|
|
88
88
|
}
|
|
89
89
|
static async shouldThrowWithBadSvcBecauseTestRouterIsReset() {
|
|
90
|
-
await
|
|
90
|
+
await test_utils_1.assert.doesThrowAsync(() =>
|
|
91
91
|
//@ts-ignore
|
|
92
92
|
this.router.redirect('waka.waka'));
|
|
93
93
|
}
|
|
94
94
|
static testRouterBuildsOptionsWithLocaleAndAuthorizer() {
|
|
95
95
|
const options = this.router.buildLoadOptions();
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
test_utils_1.assert.isTrue(options.locale instanceof calendar_utils_1.LocaleImpl);
|
|
97
|
+
test_utils_1.assert.isTrue(options.authorizer instanceof SpyAuthorizer_1.default);
|
|
98
98
|
}
|
|
99
99
|
static async assertRedirects(action) {
|
|
100
100
|
return heartwood_view_controllers_1.vcAssert.assertActionRedirects({
|
|
@@ -105,37 +105,37 @@ class RoutingTest extends AbstractSpruceFixtureTest_1.default {
|
|
|
105
105
|
}
|
|
106
106
|
RoutingTest.vcDir = spruce_skill_utils_1.diskUtil.resolvePath(__dirname, '..', '..', 'testDirsAndFiles', 'skill', 'build');
|
|
107
107
|
__decorate([
|
|
108
|
-
(0,
|
|
108
|
+
(0, test_utils_1.test)()
|
|
109
109
|
], RoutingTest, "throwsWithBadDestination", null);
|
|
110
110
|
__decorate([
|
|
111
|
-
(0,
|
|
111
|
+
(0, test_utils_1.test)()
|
|
112
112
|
], RoutingTest, "getPresentVcIsEmptyToStart", null);
|
|
113
113
|
__decorate([
|
|
114
|
-
(0,
|
|
115
|
-
(0,
|
|
114
|
+
(0, test_utils_1.test)('can get book svc', 'spruceTestFixtures.book', Book_svc_1.default),
|
|
115
|
+
(0, test_utils_1.test)('can get spy svc', 'spruceTestFixtures.spy', Spy_svc_1.default)
|
|
116
116
|
], RoutingTest, "canRedirectToGoodSvcWithoutNamespace", null);
|
|
117
117
|
__decorate([
|
|
118
|
-
(0,
|
|
119
|
-
(0,
|
|
118
|
+
(0, test_utils_1.test)('redirect calls load on destination vc if set 1', { hey: 'there' }),
|
|
119
|
+
(0, test_utils_1.test)('redirect calls load on destination vc if set 2', { what: 'the!?' })
|
|
120
120
|
], RoutingTest, "redirectTriggersLoadWithExpectedItems", null);
|
|
121
121
|
__decorate([
|
|
122
|
-
(0,
|
|
123
|
-
(0,
|
|
122
|
+
(0, test_utils_1.test)('redirect does not call load on destination vc 1', { hey: 'there' }),
|
|
123
|
+
(0, test_utils_1.test)('redirect does not call load on destination vc 2', { what: 'the!?' })
|
|
124
124
|
], RoutingTest, "redirectByDefaultDoesNotLoadWithExpectedItems", null);
|
|
125
125
|
__decorate([
|
|
126
|
-
(0,
|
|
127
|
-
(0,
|
|
126
|
+
(0, test_utils_1.test)('can hook into redirect no args', undefined),
|
|
127
|
+
(0, test_utils_1.test)('can hook into redirect args 1', { taco: 'bell' })
|
|
128
128
|
], RoutingTest, "canHookIntoRedirectEvents", null);
|
|
129
129
|
__decorate([
|
|
130
|
-
(0,
|
|
130
|
+
(0, test_utils_1.test)()
|
|
131
131
|
], RoutingTest, "canFakeRedirectToHeartwoodRoot", null);
|
|
132
132
|
__decorate([
|
|
133
|
-
(0,
|
|
133
|
+
(0, test_utils_1.test)()
|
|
134
134
|
], RoutingTest, "canSuppressBadControllerIdOnRedirect", null);
|
|
135
135
|
__decorate([
|
|
136
|
-
(0,
|
|
136
|
+
(0, test_utils_1.test)()
|
|
137
137
|
], RoutingTest, "shouldThrowWithBadSvcBecauseTestRouterIsReset", null);
|
|
138
138
|
__decorate([
|
|
139
|
-
(0,
|
|
139
|
+
(0, test_utils_1.test)()
|
|
140
140
|
], RoutingTest, "testRouterBuildsOptionsWithLocaleAndAuthorizer", null);
|
|
141
141
|
exports.default = RoutingTest;
|
|
@@ -9,7 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
12
|
+
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
13
13
|
const AbstractSpruceFixtureTest_1 = __importDefault(require("../../../tests/AbstractSpruceFixtureTest"));
|
|
14
14
|
const constants_1 = require("../../../tests/constants");
|
|
15
15
|
const login_1 = __importDefault(require("../../../tests/decorators/login"));
|
|
@@ -25,41 +25,41 @@ let TestingScopeTest = class TestingScopeTest extends AbstractSpruceFixtureTest_
|
|
|
25
25
|
this.scope.setCurrentOrganization('aoeu');
|
|
26
26
|
this.scope.clearSession();
|
|
27
27
|
const location = await this.scope.getCurrentLocation();
|
|
28
|
-
|
|
28
|
+
test_utils_1.assert.isFalsy(location);
|
|
29
29
|
}
|
|
30
30
|
static async canSetCurrentOrgToNull() {
|
|
31
31
|
this.scope.setCurrentOrganization(null);
|
|
32
32
|
const org = await this.scope.getCurrentOrganization();
|
|
33
|
-
|
|
33
|
+
test_utils_1.assert.isNull(org);
|
|
34
34
|
}
|
|
35
35
|
static async canSetCurrentLocationToNull() {
|
|
36
36
|
this.scope.setCurrentLocation(null);
|
|
37
37
|
const org = await this.organizations.getNewestOrganization();
|
|
38
|
-
|
|
38
|
+
test_utils_1.assert.isTruthy(org);
|
|
39
39
|
const location = await this.scope.getCurrentLocation();
|
|
40
|
-
|
|
40
|
+
test_utils_1.assert.isNull(location);
|
|
41
41
|
}
|
|
42
42
|
static async clearsLocationIdWhenSettingOrgId() {
|
|
43
43
|
this.scope.setCurrentLocation('aoeu');
|
|
44
44
|
this.scope.setCurrentOrganization('aoeu');
|
|
45
45
|
//@ts-ignore
|
|
46
|
-
|
|
46
|
+
test_utils_1.assert.isFalsy(this.scope.currentLocationId);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
__decorate([
|
|
50
|
-
(0,
|
|
50
|
+
(0, test_utils_1.test)()
|
|
51
51
|
], TestingScopeTest, "canResetScope", null);
|
|
52
52
|
__decorate([
|
|
53
|
-
(0,
|
|
53
|
+
(0, test_utils_1.test)(),
|
|
54
54
|
(0, seed_1.default)('organizations', 1)
|
|
55
55
|
], TestingScopeTest, "canSetCurrentOrgToNull", null);
|
|
56
56
|
__decorate([
|
|
57
|
-
(0,
|
|
57
|
+
(0, test_utils_1.test)(),
|
|
58
58
|
(0, seed_1.default)('organizations', 1),
|
|
59
59
|
(0, seed_1.default)('locations', 1)
|
|
60
60
|
], TestingScopeTest, "canSetCurrentLocationToNull", null);
|
|
61
61
|
__decorate([
|
|
62
|
-
(0,
|
|
62
|
+
(0, test_utils_1.test)()
|
|
63
63
|
], TestingScopeTest, "clearsLocationIdWhenSettingOrgId", null);
|
|
64
64
|
TestingScopeTest = __decorate([
|
|
65
65
|
(0, login_1.default)(constants_1.DEMO_NUMBER_SCOPE)
|