diff --git a/.fernignore b/.fernignore index 07281cd..6972c40 100644 --- a/.fernignore +++ b/.fernignore @@ -2,3 +2,7 @@ README.md changelog.md +tests/unit/types/SayHookAction.test.ts + +# PRO-3057: Manually fixed incorrect type for exact field (was Record, should be string | string[]) +src/api/types/SayHookAction.ts diff --git a/src/api/types/SayHookAction.ts b/src/api/types/SayHookAction.ts index c5273d2..2005f3b 100644 --- a/src/api/types/SayHookAction.ts +++ b/src/api/types/SayHookAction.ts @@ -9,5 +9,5 @@ export interface SayHookAction { */ prompt?: Vapi.SayHookActionPrompt | undefined; /** This is the message to say */ - exact?: Record | undefined; + exact?: string | string[] | undefined; } diff --git a/tests/unit/types/SayHookAction.test.ts b/tests/unit/types/SayHookAction.test.ts new file mode 100644 index 0000000..123612f --- /dev/null +++ b/tests/unit/types/SayHookAction.test.ts @@ -0,0 +1,31 @@ +import type { SayHookAction } from "../../../src/api/types/SayHookAction.js"; + +describe("SayHookAction", () => { + it("should accept a string for exact", () => { + const action: SayHookAction = { + exact: "Hello, how can I help you?", + }; + expect(action.exact).toBe("Hello, how can I help you?"); + }); + + it("should accept a string array for exact", () => { + const action: SayHookAction = { + exact: ["Hello!", "How can I help you?"], + }; + expect(action.exact).toEqual(["Hello!", "How can I help you?"]); + }); + + it("should allow exact to be undefined", () => { + const action: SayHookAction = {}; + expect(action.exact).toBeUndefined(); + }); + + it("should allow both prompt and exact to be set", () => { + const action: SayHookAction = { + prompt: "Greet the user warmly", + exact: "Welcome!", + }; + expect(action.prompt).toBe("Greet the user warmly"); + expect(action.exact).toBe("Welcome!"); + }); +});