@sprucelabs/spruce-agent-utils 0.1.0 → 0.2.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.
@@ -3,5 +3,6 @@ declare const agentAssert: {
3
3
  beforeEach(client: MercuryClient): Promise<void>;
4
4
  getName: () => string;
5
5
  includesAgentName: (text: string) => void;
6
+ actionCallsSetup: (action: () => Promise<void>) => Promise<void>;
6
7
  };
7
8
  export default agentAssert;
@@ -26,5 +26,15 @@ const agentAssert = {
26
26
  (0, schema_1.assertOptions)({ text }, ['text']);
27
27
  test_utils_1.assert.doesInclude(text, name, `The text must include agent name!`);
28
28
  },
29
+ actionCallsSetup: async (action) => {
30
+ SpruceAgent_1.default.reset();
31
+ await action();
32
+ try {
33
+ SpruceAgent_1.default.getInstance();
34
+ }
35
+ catch {
36
+ test_utils_1.assert.fail('SpruceAgent.setup was not called during action!');
37
+ }
38
+ },
29
39
  };
30
40
  exports.default = agentAssert;
@@ -11,7 +11,7 @@ class SpruceError extends error_1.default {
11
11
  let message;
12
12
  switch (options?.code) {
13
13
  case 'AGENT_LOADER_NOT_CONFIGURED':
14
- message = `The agent loader has not been configured. Please call SpruceAgent.setup(...) first. Best place is probably in the did-boot of your skill or the constructor of your AppViewController in the front-end.`;
14
+ message = `The agent loader has not been configured. Please call SpruceAgent.setup(...) first. If you are booting your skill, add it to the did-boot. If this is a front-end test, do it in the AppController. If your test has neither of those, just do it in the beforeEach() and make sure to do a new test for where it needs to be called in the production code.`;
15
15
  break;
16
16
  default:
17
17
  message = super.friendlyMessage();
@@ -3,5 +3,6 @@ declare const agentAssert: {
3
3
  beforeEach(client: MercuryClient): Promise<void>;
4
4
  getName: () => string;
5
5
  includesAgentName: (text: string) => void;
6
+ actionCallsSetup: (action: () => Promise<void>) => Promise<void>;
6
7
  };
7
8
  export default agentAssert;
@@ -21,5 +21,15 @@ const agentAssert = {
21
21
  assertOptions({ text }, ['text']);
22
22
  assert.doesInclude(text, name, `The text must include agent name!`);
23
23
  },
24
+ actionCallsSetup: async (action) => {
25
+ SpruceAgent.reset();
26
+ await action();
27
+ try {
28
+ SpruceAgent.getInstance();
29
+ }
30
+ catch {
31
+ assert.fail('SpruceAgent.setup was not called during action!');
32
+ }
33
+ },
24
34
  };
25
35
  export default agentAssert;
@@ -6,7 +6,7 @@ export default class SpruceError extends BaseSpruceError {
6
6
  let message;
7
7
  switch (options === null || options === void 0 ? void 0 : options.code) {
8
8
  case 'AGENT_LOADER_NOT_CONFIGURED':
9
- message = `The agent loader has not been configured. Please call SpruceAgent.setup(...) first. Best place is probably in the did-boot of your skill or the constructor of your AppViewController in the front-end.`;
9
+ message = `The agent loader has not been configured. Please call SpruceAgent.setup(...) first. If you are booting your skill, add it to the did-boot. If this is a front-end test, do it in the AppController. If your test has neither of those, just do it in the beforeEach() and make sure to do a new test for where it needs to be called in the production code.`;
10
10
  break;
11
11
  default:
12
12
  message = super.friendlyMessage();
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "!build/__tests__",
9
9
  "esm"
10
10
  ],
11
- "version": "0.1.0",
11
+ "version": "0.2.0",
12
12
  "main": "./build/index.js",
13
13
  "types": "./build/index.d.ts",
14
14
  "module": "./build/esm/index.js",