@sprucelabs/spruce-location-utils 2.0.6 → 2.0.7

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.
@@ -0,0 +1,16 @@
1
+ import { SkillViewController } from '@sprucelabs/heartwood-view-controllers';
2
+ import { OrganizationFixture, ViewFixture } from '@sprucelabs/spruce-test-fixtures';
3
+ declare const organizationAssert: {
4
+ assertRedirectsToAddOrgIfNoOrgExists(options: {
5
+ viewFixture: ViewFixture;
6
+ organizationFixture: OrganizationFixture;
7
+ vc: SkillViewController<any>;
8
+ didAddOrgRedirectDestination: string;
9
+ }): Promise<void>;
10
+ assertDoesNotRedirectToAddAOrgIfOrgExists(options: {
11
+ vc: SkillViewController<any>;
12
+ viewFixture: ViewFixture;
13
+ organizationFixture: OrganizationFixture;
14
+ }): Promise<void>;
15
+ };
16
+ export default organizationAssert;
@@ -0,0 +1,62 @@
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
+ import { vcAssertUtil, } from '@sprucelabs/heartwood-view-controllers';
11
+ import { assertOptions } from '@sprucelabs/schema';
12
+ import { TestRouter, } from '@sprucelabs/spruce-test-fixtures';
13
+ import { assert } from '@sprucelabs/test';
14
+ const organizationAssert = {
15
+ assertRedirectsToAddOrgIfNoOrgExists(options) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ assertOptions(options, [
18
+ 'viewFixture',
19
+ 'vc',
20
+ 'organizationFixture',
21
+ 'didAddOrgRedirectDestination',
22
+ ]);
23
+ const { viewFixture, vc, organizationFixture, didAddOrgRedirectDestination: redirectDestination, } = options;
24
+ yield organizationFixture.deleteAllOrganizations();
25
+ TestRouter.setShouldThrowWhenRedirectingToBadSvc(false);
26
+ const router = viewFixture.getRouter();
27
+ yield vcAssertUtil.assertActionRedirects({
28
+ router,
29
+ action: () => viewFixture.load(vc),
30
+ destination: {
31
+ id: 'organization.add',
32
+ args: {
33
+ redirect: {
34
+ id: redirectDestination,
35
+ },
36
+ },
37
+ },
38
+ });
39
+ TestRouter.setShouldThrowWhenRedirectingToBadSvc(true);
40
+ });
41
+ },
42
+ assertDoesNotRedirectToAddAOrgIfOrgExists(options) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ assertOptions(options, ['viewFixture', 'vc', 'organizationFixture']);
45
+ const { vc, viewFixture, organizationFixture } = options;
46
+ yield viewFixture.loginAsDemoPerson();
47
+ const latest = yield organizationFixture.getNewestOrganization();
48
+ if (!latest) {
49
+ yield organizationFixture.seedDemoOrganization();
50
+ }
51
+ let wasHit = false;
52
+ yield viewFixture.getRouter().on('did-redirect', () => {
53
+ wasHit = true;
54
+ });
55
+ TestRouter.setShouldThrowWhenRedirectingToBadSvc(false);
56
+ yield viewFixture.load(vc);
57
+ TestRouter.setShouldThrowWhenRedirectingToBadSvc(true);
58
+ assert.isFalse(wasHit, `I was redirected and didn't expect to be.`);
59
+ });
60
+ },
61
+ };
62
+ export default organizationAssert;
@@ -0,0 +1,16 @@
1
+ import { SkillViewController } from '@sprucelabs/heartwood-view-controllers';
2
+ import { OrganizationFixture, ViewFixture } from '@sprucelabs/spruce-test-fixtures';
3
+ declare const organizationAssert: {
4
+ assertRedirectsToAddOrgIfNoOrgExists(options: {
5
+ viewFixture: ViewFixture;
6
+ organizationFixture: OrganizationFixture;
7
+ vc: SkillViewController<any>;
8
+ didAddOrgRedirectDestination: string;
9
+ }): Promise<void>;
10
+ assertDoesNotRedirectToAddAOrgIfOrgExists(options: {
11
+ vc: SkillViewController<any>;
12
+ viewFixture: ViewFixture;
13
+ organizationFixture: OrganizationFixture;
14
+ }): Promise<void>;
15
+ };
16
+ export default organizationAssert;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
4
+ const schema_1 = require("@sprucelabs/schema");
5
+ const spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
6
+ const test_1 = require("@sprucelabs/test");
7
+ const organizationAssert = {
8
+ async assertRedirectsToAddOrgIfNoOrgExists(options) {
9
+ (0, schema_1.assertOptions)(options, [
10
+ 'viewFixture',
11
+ 'vc',
12
+ 'organizationFixture',
13
+ 'didAddOrgRedirectDestination',
14
+ ]);
15
+ const { viewFixture, vc, organizationFixture, didAddOrgRedirectDestination: redirectDestination, } = options;
16
+ await organizationFixture.deleteAllOrganizations();
17
+ spruce_test_fixtures_1.TestRouter.setShouldThrowWhenRedirectingToBadSvc(false);
18
+ const router = viewFixture.getRouter();
19
+ await heartwood_view_controllers_1.vcAssertUtil.assertActionRedirects({
20
+ router,
21
+ action: () => viewFixture.load(vc),
22
+ destination: {
23
+ id: 'organization.add',
24
+ args: {
25
+ redirect: {
26
+ id: redirectDestination,
27
+ },
28
+ },
29
+ },
30
+ });
31
+ spruce_test_fixtures_1.TestRouter.setShouldThrowWhenRedirectingToBadSvc(true);
32
+ },
33
+ async assertDoesNotRedirectToAddAOrgIfOrgExists(options) {
34
+ (0, schema_1.assertOptions)(options, ['viewFixture', 'vc', 'organizationFixture']);
35
+ const { vc, viewFixture, organizationFixture } = options;
36
+ await viewFixture.loginAsDemoPerson();
37
+ const latest = await organizationFixture.getNewestOrganization();
38
+ if (!latest) {
39
+ await organizationFixture.seedDemoOrganization();
40
+ }
41
+ let wasHit = false;
42
+ await viewFixture.getRouter().on('did-redirect', () => {
43
+ wasHit = true;
44
+ });
45
+ spruce_test_fixtures_1.TestRouter.setShouldThrowWhenRedirectingToBadSvc(false);
46
+ await viewFixture.load(vc);
47
+ spruce_test_fixtures_1.TestRouter.setShouldThrowWhenRedirectingToBadSvc(true);
48
+ test_1.assert.isFalse(wasHit, `I was redirected and didn't expect to be.`);
49
+ },
50
+ };
51
+ exports.default = organizationAssert;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-location-utils",
3
3
  "description": "Location Utilities",
4
- "version": "2.0.6",
4
+ "version": "2.0.7",
5
5
  "skill": {
6
6
  "namespace": "locations"
7
7
  },
@@ -16,12 +16,12 @@
16
16
  "files": [
17
17
  "build/index-module.js",
18
18
  "build/index-module.d.ts",
19
- "build/tests/utilities/organizationAssert.utility.js",
20
- "build/tests/utilities/organizationAssert.utility.d.ts",
19
+ "build/tests/utilities/organizationAssert.js",
20
+ "build/tests/utilities/organizationAssert.d.ts",
21
21
  "build/esm/index-module.js",
22
22
  "build/esm/index-module.d.ts",
23
- "build/esm/tests/utilities/organizationAssert.utility.js",
24
- "build/esm/tests/utilities/organizationAssert.utility.d.ts"
23
+ "build/esm/tests/utilities/organizationAssert.js",
24
+ "build/esm/tests/utilities/organizationAssert.d.ts"
25
25
  ],
26
26
  "keywords": [],
27
27
  "scripts": {
@@ -36,4 +36,4 @@
36
36
  "node": "16.x",
37
37
  "yarn": "1.x"
38
38
  }
39
- }
39
+ }