@sprucelabs/spruce-location-utils 9.3.0 → 9.4.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.
@@ -1,3 +1,5 @@
1
1
  export { default as organizationAssert } from './tests/organizationAssert';
2
2
  export { default as LocationListCardViewController } from './viewControllers/LocationListCard.vc';
3
+ export { default as locationListCardAssert } from './tests/locationListCardAssert';
4
+ export * from './tests/locationListCardAssert';
3
5
  export * from './types-module';
@@ -1,3 +1,5 @@
1
1
  export { default as organizationAssert } from './tests/organizationAssert.js';
2
2
  export { default as LocationListCardViewController } from './viewControllers/LocationListCard.vc.js';
3
+ export { default as locationListCardAssert } from './tests/locationListCardAssert.js';
4
+ export * from './tests/locationListCardAssert.js';
3
5
  export * from './types-module.js';
@@ -0,0 +1,16 @@
1
+ import { Card, SpruceSchemas, ViewController, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
2
+ import { ViewFixture } from '@sprucelabs/spruce-test-fixtures';
3
+ import LocationListCardViewController, { LocationListCardViewControllerOptions as LocationListCardOptions } from '../viewControllers/LocationListCard.vc';
4
+ declare const locationListCardAssert: {
5
+ beforeEach(views: Pick<ViewFixture, 'setController'>): void;
6
+ loadsWithTargetAndPayload(options: LoadsWithTargetAndPayloadOptions): Promise<void>;
7
+ configurationEquals(vc: ViewController<Card>, options: LocationListCardOptions): void;
8
+ };
9
+ export declare class SpyLocationListCard extends LocationListCardViewController {
10
+ constructorOptions: LocationListCardOptions;
11
+ constructor(options: ViewControllerOptions & LocationListCardOptions);
12
+ }
13
+ export type LoadsWithTargetAndPayloadOptions = Partial<SpruceSchemas.Mercury.v2020_12_25.ListLocationsEmitTargetAndPayload> & {
14
+ action: () => Promise<void> | void;
15
+ };
16
+ export default locationListCardAssert;
@@ -0,0 +1,52 @@
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 { eventFaker } from '@sprucelabs/spruce-test-fixtures';
11
+ import { assert } from '@sprucelabs/test-utils';
12
+ import LocationListCardViewController from '../viewControllers/LocationListCard.vc.js';
13
+ const locationListCardAssert = {
14
+ beforeEach(views) {
15
+ views.setController('locations.list-card', SpyLocationListCard);
16
+ },
17
+ loadsWithTargetAndPayload(options) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const { action, target, payload } = options;
20
+ let passedTarget;
21
+ let passedPayload;
22
+ yield eventFaker.on('list-locations::v2020_12_25', ({ target, payload }) => {
23
+ passedPayload = payload;
24
+ passedTarget = target;
25
+ return {
26
+ locations: [],
27
+ };
28
+ });
29
+ yield action();
30
+ if (target) {
31
+ assert.isEqualDeep(passedTarget, target, 'Target missmatch');
32
+ }
33
+ if (payload) {
34
+ assert.isEqualDeep(passedPayload, payload, 'Payload missmatch');
35
+ }
36
+ });
37
+ },
38
+ configurationEquals(vc, options) {
39
+ const spyVc = vc;
40
+ const keys = Object.keys(options);
41
+ for (const key of keys) {
42
+ assert.isEqualDeep(spyVc.constructorOptions[key], options[key], 'Missmatch on ' + key);
43
+ }
44
+ },
45
+ };
46
+ export class SpyLocationListCard extends LocationListCardViewController {
47
+ constructor(options) {
48
+ super(options);
49
+ this.constructorOptions = options;
50
+ }
51
+ }
52
+ export default locationListCardAssert;
@@ -26,7 +26,7 @@ type OnEditHandler = (location: Location) => void;
26
26
  export type LocationListCardViewControllerOptions = {
27
27
  onDelete?: OnDeleteHandler;
28
28
  onClick?: OnEditHandler;
29
- currentOrganizationId: string;
29
+ currentOrganizationId?: string;
30
30
  selectedLocationId?: string;
31
31
  footerButtons?: Button[];
32
32
  shouldRenderDeleteButtons?: boolean;
@@ -1,3 +1,5 @@
1
1
  export { default as organizationAssert } from './tests/organizationAssert';
2
2
  export { default as LocationListCardViewController } from './viewControllers/LocationListCard.vc';
3
+ export { default as locationListCardAssert } from './tests/locationListCardAssert';
4
+ export * from './tests/locationListCardAssert';
3
5
  export * from './types-module';
@@ -17,9 +17,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.LocationListCardViewController = exports.organizationAssert = void 0;
20
+ exports.locationListCardAssert = exports.LocationListCardViewController = exports.organizationAssert = void 0;
21
21
  var organizationAssert_1 = require("./tests/organizationAssert");
22
22
  Object.defineProperty(exports, "organizationAssert", { enumerable: true, get: function () { return __importDefault(organizationAssert_1).default; } });
23
23
  var LocationListCard_vc_1 = require("./viewControllers/LocationListCard.vc");
24
24
  Object.defineProperty(exports, "LocationListCardViewController", { enumerable: true, get: function () { return __importDefault(LocationListCard_vc_1).default; } });
25
+ var locationListCardAssert_1 = require("./tests/locationListCardAssert");
26
+ Object.defineProperty(exports, "locationListCardAssert", { enumerable: true, get: function () { return __importDefault(locationListCardAssert_1).default; } });
27
+ __exportStar(require("./tests/locationListCardAssert"), exports);
25
28
  __exportStar(require("./types-module"), exports);
@@ -0,0 +1,16 @@
1
+ import { Card, SpruceSchemas, ViewController, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
2
+ import { ViewFixture } from '@sprucelabs/spruce-test-fixtures';
3
+ import LocationListCardViewController, { LocationListCardViewControllerOptions as LocationListCardOptions } from '../viewControllers/LocationListCard.vc';
4
+ declare const locationListCardAssert: {
5
+ beforeEach(views: Pick<ViewFixture, 'setController'>): void;
6
+ loadsWithTargetAndPayload(options: LoadsWithTargetAndPayloadOptions): Promise<void>;
7
+ configurationEquals(vc: ViewController<Card>, options: LocationListCardOptions): void;
8
+ };
9
+ export declare class SpyLocationListCard extends LocationListCardViewController {
10
+ constructorOptions: LocationListCardOptions;
11
+ constructor(options: ViewControllerOptions & LocationListCardOptions);
12
+ }
13
+ export type LoadsWithTargetAndPayloadOptions = Partial<SpruceSchemas.Mercury.v2020_12_25.ListLocationsEmitTargetAndPayload> & {
14
+ action: () => Promise<void> | void;
15
+ };
16
+ export default locationListCardAssert;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SpyLocationListCard = void 0;
7
+ const spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
8
+ const test_utils_1 = require("@sprucelabs/test-utils");
9
+ const LocationListCard_vc_1 = __importDefault(require("../viewControllers/LocationListCard.vc"));
10
+ const locationListCardAssert = {
11
+ beforeEach(views) {
12
+ views.setController('locations.list-card', SpyLocationListCard);
13
+ },
14
+ async loadsWithTargetAndPayload(options) {
15
+ const { action, target, payload } = options;
16
+ let passedTarget;
17
+ let passedPayload;
18
+ await spruce_test_fixtures_1.eventFaker.on('list-locations::v2020_12_25', ({ target, payload }) => {
19
+ passedPayload = payload;
20
+ passedTarget = target;
21
+ return {
22
+ locations: [],
23
+ };
24
+ });
25
+ await action();
26
+ if (target) {
27
+ test_utils_1.assert.isEqualDeep(passedTarget, target, 'Target missmatch');
28
+ }
29
+ if (payload) {
30
+ test_utils_1.assert.isEqualDeep(passedPayload, payload, 'Payload missmatch');
31
+ }
32
+ },
33
+ configurationEquals(vc, options) {
34
+ const spyVc = vc;
35
+ const keys = Object.keys(options);
36
+ for (const key of keys) {
37
+ test_utils_1.assert.isEqualDeep(spyVc.constructorOptions[key], options[key], 'Missmatch on ' + key);
38
+ }
39
+ },
40
+ };
41
+ class SpyLocationListCard extends LocationListCard_vc_1.default {
42
+ constructor(options) {
43
+ super(options);
44
+ this.constructorOptions = options;
45
+ }
46
+ }
47
+ exports.SpyLocationListCard = SpyLocationListCard;
48
+ exports.default = locationListCardAssert;
@@ -26,7 +26,7 @@ type OnEditHandler = (location: Location) => void;
26
26
  export type LocationListCardViewControllerOptions = {
27
27
  onDelete?: OnDeleteHandler;
28
28
  onClick?: OnEditHandler;
29
- currentOrganizationId: string;
29
+ currentOrganizationId?: string;
30
30
  selectedLocationId?: string;
31
31
  footerButtons?: Button[];
32
32
  shouldRenderDeleteButtons?: boolean;
package/package.json CHANGED
@@ -1,47 +1,51 @@
1
1
  {
2
- "name": "@sprucelabs/spruce-location-utils",
3
- "description": "Location Utilities",
4
- "version": "9.3.0",
5
- "skill": {
6
- "namespace": "locations"
7
- },
8
- "homepage": "https://github.com/sprucelabsai/spruce-locations-skill",
9
- "bugs": {
10
- "url": "https://github.com/sprucelabsai/spruce-locations-skill/issues"
11
- },
12
- "main": "./build/index-module.js",
13
- "types": "./build/index-module.d.ts",
14
- "module": "./build/esm/index-module.js",
15
- "sideEffects": false,
16
- "files": [
17
- "build/index-module.js",
18
- "build/index-module.d.ts",
19
- "build/tests/organizationAssert.js",
20
- "build/tests/organizationAssert.d.ts",
21
- "build/viewControllers/LocationListCard.vc.js",
22
- "build/viewControllers/LocationListCard.vc.d.ts",
23
- "build/esm/index-module.js",
24
- "build/esm/index-module.d.ts",
25
- "build/esm/tests/organizationAssert.js",
26
- "build/esm/tests/organizationAssert.d.ts",
27
- "build/esm/viewControllers/LocationListCard.vc.js",
28
- "build/esm/viewControllers/LocationListCard.vc.d.ts",
29
- "build/types-module.js",
30
- "build/types-module.d.ts",
31
- "build/esm/types-module.js",
32
- "build/esm/types-module.d.ts"
33
- ],
34
- "keywords": [],
35
- "scripts": {
36
- "release": "npm publish"
37
- },
38
- "dependencies": {
39
- "@sprucelabs/heartwood-view-controllers": "latest",
40
- "@sprucelabs/spruce-event-utils": "latest",
41
- "@sprucelabs/spruce-test-fixtures": "latest",
42
- "@sprucelabs/test-utils": "latest"
43
- },
44
- "engines": {
45
- "yarn": "1.x"
46
- }
47
- }
2
+ "name": "@sprucelabs/spruce-location-utils",
3
+ "description": "Location Utilities",
4
+ "version": "9.4.0",
5
+ "skill": {
6
+ "namespace": "locations"
7
+ },
8
+ "homepage": "https://github.com/sprucelabsai/spruce-locations-skill",
9
+ "bugs": {
10
+ "url": "https://github.com/sprucelabsai/spruce-locations-skill/issues"
11
+ },
12
+ "main": "./build/index-module.js",
13
+ "types": "./build/index-module.d.ts",
14
+ "module": "./build/esm/index-module.js",
15
+ "sideEffects": false,
16
+ "files": [
17
+ "build/index-module.js",
18
+ "build/index-module.d.ts",
19
+ "build/tests/organizationAssert.js",
20
+ "build/tests/organizationAssert.d.ts",
21
+ "build/esm/tests/organizationAssert.js",
22
+ "build/esm/tests/organizationAssert.d.ts",
23
+ "build/viewControllers/LocationListCard.vc.js",
24
+ "build/viewControllers/LocationListCard.vc.d.ts",
25
+ "build/esm/index-module.js",
26
+ "build/esm/index-module.d.ts",
27
+ "build/esm/viewControllers/LocationListCard.vc.js",
28
+ "build/esm/viewControllers/LocationListCard.vc.d.ts",
29
+ "build/types-module.js",
30
+ "build/types-module.d.ts",
31
+ "build/esm/types-module.js",
32
+ "build/esm/types-module.d.ts",
33
+ "build/tests/locationListCardAssert.js",
34
+ "build/tests/locationListCardAssert.d.ts",
35
+ "build/esm/tests/locationListCardAssert.js",
36
+ "build/esm/tests/locationListCardAssert.d.ts"
37
+ ],
38
+ "keywords": [],
39
+ "scripts": {
40
+ "release": "npm publish"
41
+ },
42
+ "dependencies": {
43
+ "@sprucelabs/heartwood-view-controllers": "latest",
44
+ "@sprucelabs/spruce-event-utils": "latest",
45
+ "@sprucelabs/spruce-test-fixtures": "latest",
46
+ "@sprucelabs/test-utils": "latest"
47
+ },
48
+ "engines": {
49
+ "yarn": "1.x"
50
+ }
51
+ }