Path: blob/main/components/dashboard/src/data/workspaces/workspace-classes-query.test.ts
2501 views
/**1* Copyright (c) 2024 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56import { AllowedWorkspaceClass, getNextDefaultClass } from "./workspace-classes-query";78test("getNextDefaultClass", async () => {9const allClasses: AllowedWorkspaceClass[] = [10{ id: "cls-1" },11{ id: "cls-2", isDisabledInScope: true },12{ id: "cls-3" },13{ id: "cls-4", isDisabledInScope: true },14{ id: "cls-5" },15{ id: "cls-6" },16{ id: "cls-7" },17] as any;18type ArgsType = Parameters<typeof getNextDefaultClass>;19const testCases: {20args: ArgsType;21expected: ReturnType<typeof getNextDefaultClass>;22}[] = [23{ args: [allClasses, undefined], expected: undefined },24{ args: [allClasses, "cls-2"], expected: "cls-1" },25{ args: [allClasses, "cls-4"], expected: "cls-3" },26{ args: [allClasses, "cls-5"], expected: "cls-5" },27{ args: [[], "cls-3"], expected: undefined },28{ args: [allClasses.map((e) => ({ ...e, isDisabledInScope: true })), "cls-3"], expected: undefined },29];3031for (const t of testCases) {32const actual = getNextDefaultClass(...t.args);33expect(actual).toBe(t.expected);34}35});363738