From aee8249ffa0ac7418e64fee815ab0d382c82a61e Mon Sep 17 00:00:00 2001 From: Asier Isayas Date: Thu, 20 Mar 2025 13:38:51 -0400 Subject: [PATCH] fix self serve tests --- src/SelfServe/SelfServeUtils.test.tsx | 31 +++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/SelfServe/SelfServeUtils.test.tsx b/src/SelfServe/SelfServeUtils.test.tsx index fa55641ac..1c754bc96 100644 --- a/src/SelfServe/SelfServeUtils.test.tsx +++ b/src/SelfServe/SelfServeUtils.test.tsx @@ -7,45 +7,48 @@ import { } from "./SelfServeUtils"; describe("SelfServeUtils", () => { + const getSelfServeTypeExample = (): SelfServeType => { + return SelfServeType.example; + }; + it("initialize should be declared for self serve classes", () => { - class Test extends SelfServeBaseClass { + class SelfServeExample extends SelfServeBaseClass { public initialize: () => Promise>; public onSave: (currentValues: Map) => Promise; public onRefresh: () => Promise; - public getSelfServeType: () => SelfServeType; + public getSelfServeType = (): SelfServeType => getSelfServeTypeExample(); } - expect(() => new Test().toSelfServeDescriptor()).toThrow("initialize() was not declared for the class 'Test'"); + expect(() => new SelfServeExample().toSelfServeDescriptor()).toThrow("initialize() was not declared for the class 'SelfServeExample'"); }); - it("onSave should be declared for self serve classes", () => { - class Test extends SelfServeBaseClass { + class SelfServeExample extends SelfServeBaseClass { public initialize = jest.fn(); public onSave: () => Promise; public onRefresh: () => Promise; - public getSelfServeType: () => SelfServeType; + public getSelfServeType = (): SelfServeType => getSelfServeTypeExample(); } - expect(() => new Test().toSelfServeDescriptor()).toThrow("onSave() was not declared for the class 'Test'"); + expect(() => new SelfServeExample().toSelfServeDescriptor()).toThrow("onSave() was not declared for the class 'SelfServeExample'"); }); it("onRefresh should be declared for self serve classes", () => { - class Test extends SelfServeBaseClass { + class SelfServeExample extends SelfServeBaseClass { public initialize = jest.fn(); public onSave = jest.fn(); public onRefresh: () => Promise; - public getSelfServeType: () => SelfServeType; + public getSelfServeType = (): SelfServeType => getSelfServeTypeExample(); } - expect(() => new Test().toSelfServeDescriptor()).toThrow("onRefresh() was not declared for the class 'Test'"); + expect(() => new SelfServeExample().toSelfServeDescriptor()).toThrow("onRefresh() was not declared for the class 'SelfServeExample'"); }); it("@IsDisplayable decorator must be present for self serve classes", () => { - class Test extends SelfServeBaseClass { + class SelfServeExample extends SelfServeBaseClass { public initialize = jest.fn(); public onSave = jest.fn(); public onRefresh = jest.fn(); - public getSelfServeType = jest.fn(); + public getSelfServeType = (): SelfServeType => getSelfServeTypeExample(); } - expect(() => new Test().toSelfServeDescriptor()).toThrow( - "@IsDisplayable decorator was not declared for the class 'Test'", + expect(() => new SelfServeExample().toSelfServeDescriptor()).toThrow( + "@IsDisplayable decorator was not declared for the class 'SelfServeExample'", ); });