@sprucelabs/spruce-heartwood-utils 19.5.12 → 19.6.1

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,4 +1,4 @@
1
- import { ViewControllerMap, ControllerOptions, ViewController } from '@sprucelabs/heartwood-view-controllers';
1
+ import { ViewControllerMap, ControllerOptions, ViewController, SkillViewController } from '@sprucelabs/heartwood-view-controllers';
2
2
  import { RemoteFactoryOptions, RemoteViewControllerFactory } from '../../skillViews/RemoteViewControllerFactory';
3
3
  export default class MockRemoteViewControllerFactory implements RemoteViewControllerFactory {
4
4
  private static instance?;
@@ -10,9 +10,12 @@ export default class MockRemoteViewControllerFactory implements RemoteViewContro
10
10
  id: string;
11
11
  }>;
12
12
  Controller<N extends keyof ViewControllerMap, O extends ControllerOptions<N>>(_name: N, _options: O): ViewControllerMap[N];
13
+ dropInRemoteController(id: string, Class: new (args: any) => ViewController<any>): void;
14
+ assertSkillViewRendersRemoteCard(vc: SkillViewController, id: string): void;
13
15
  static reset(): void;
14
16
  static getInstance(): MockRemoteViewControllerFactory;
15
17
  getTheme(_namespace?: string | undefined): undefined;
18
+ assertDidNotFetchRemoteController(id: string): void;
16
19
  assertFetchedRemoteController(id: string, options?: Record<string, any>): void;
17
20
  hasController(name: string): boolean;
18
21
  RemoteController(name: string, options: Record<string, any>): Promise<any>;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
3
4
  const test_utils_1 = require("@sprucelabs/test-utils");
4
5
  class MockRemoteViewControllerFactory {
5
6
  constructor(options) {
@@ -13,6 +14,15 @@ class MockRemoteViewControllerFactory {
13
14
  Controller(_name, _options) {
14
15
  return {};
15
16
  }
17
+ dropInRemoteController(id, Class) {
18
+ this.views.setController(id, Class);
19
+ }
20
+ assertSkillViewRendersRemoteCard(vc, id) {
21
+ const cards = heartwood_view_controllers_1.vcAssert.assertSkillViewRendersCards(vc);
22
+ test_utils_1.assert.isTruthy(
23
+ //@ts-ignore
24
+ cards.find((c) => c.id === id), `Could not find the remote card with the id '${id}'!`);
25
+ }
16
26
  static reset() {
17
27
  delete this.instance;
18
28
  }
@@ -25,6 +35,15 @@ class MockRemoteViewControllerFactory {
25
35
  getTheme(_namespace) {
26
36
  return undefined;
27
37
  }
38
+ assertDidNotFetchRemoteController(id) {
39
+ try {
40
+ this.assertFetchedRemoteController(id);
41
+ }
42
+ catch (_a) {
43
+ return;
44
+ }
45
+ test_utils_1.assert.fail(`You fetched the controller with the id '${id}' but you should not have.`);
46
+ }
28
47
  assertFetchedRemoteController(id, options) {
29
48
  test_utils_1.assert.isTrue(this.hasController(id), `You never tried to fetch a controller with the id '${id}'. Try remoteViews.RemoteController(...)`);
30
49
  if (options) {
@@ -1,4 +1,4 @@
1
- import { ViewControllerMap, ControllerOptions, ViewController } from '@sprucelabs/heartwood-view-controllers';
1
+ import { ViewControllerMap, ControllerOptions, ViewController, SkillViewController } from '@sprucelabs/heartwood-view-controllers';
2
2
  import { RemoteFactoryOptions, RemoteViewControllerFactory } from '../../skillViews/RemoteViewControllerFactory';
3
3
  export default class MockRemoteViewControllerFactory implements RemoteViewControllerFactory {
4
4
  private static instance?;
@@ -10,9 +10,12 @@ export default class MockRemoteViewControllerFactory implements RemoteViewContro
10
10
  id: string;
11
11
  }>;
12
12
  Controller<N extends keyof ViewControllerMap, O extends ControllerOptions<N>>(_name: N, _options: O): ViewControllerMap[N];
13
+ dropInRemoteController(id: string, Class: new (args: any) => ViewController<any>): void;
14
+ assertSkillViewRendersRemoteCard(vc: SkillViewController, id: string): void;
13
15
  static reset(): void;
14
16
  static getInstance(): MockRemoteViewControllerFactory;
15
17
  getTheme(_namespace?: string | undefined): undefined;
18
+ assertDidNotFetchRemoteController(id: string): void;
16
19
  assertFetchedRemoteController(id: string, options?: Record<string, any>): void;
17
20
  hasController(name: string): boolean;
18
21
  RemoteController(name: string, options: Record<string, any>): Promise<any>;
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import { vcAssert, } from '@sprucelabs/heartwood-view-controllers';
10
11
  import { assert } from '@sprucelabs/test-utils';
11
12
  export default class MockRemoteViewControllerFactory {
12
13
  constructor(options) {
@@ -20,6 +21,15 @@ export default class MockRemoteViewControllerFactory {
20
21
  Controller(_name, _options) {
21
22
  return {};
22
23
  }
24
+ dropInRemoteController(id, Class) {
25
+ this.views.setController(id, Class);
26
+ }
27
+ assertSkillViewRendersRemoteCard(vc, id) {
28
+ const cards = vcAssert.assertSkillViewRendersCards(vc);
29
+ assert.isTruthy(
30
+ //@ts-ignore
31
+ cards.find((c) => c.id === id), `Could not find the remote card with the id '${id}'!`);
32
+ }
23
33
  static reset() {
24
34
  delete this.instance;
25
35
  }
@@ -32,6 +42,15 @@ export default class MockRemoteViewControllerFactory {
32
42
  getTheme(_namespace) {
33
43
  return undefined;
34
44
  }
45
+ assertDidNotFetchRemoteController(id) {
46
+ try {
47
+ this.assertFetchedRemoteController(id);
48
+ }
49
+ catch (_a) {
50
+ return;
51
+ }
52
+ assert.fail(`You fetched the controller with the id '${id}' but you should not have.`);
53
+ }
35
54
  assertFetchedRemoteController(id, options) {
36
55
  assert.isTrue(this.hasController(id), `You never tried to fetch a controller with the id '${id}'. Try remoteViews.RemoteController(...)`);
37
56
  if (options) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-heartwood-utils",
3
3
  "description": "Heartwood Utilities",
4
- "version": "19.5.12",
4
+ "version": "19.6.1",
5
5
  "skill": {
6
6
  "namespace": "heartwood"
7
7
  },