// build testsfor this: // static extractSeatDetails(arr: IUserEventModel[], convertToString?: boolean): string[] | string { // const seatDetails: Array = []; // arr.forEach((item: IUserEventModel) => { // if (item.ticketsInfo?.length) { // item.ticketsInfo.forEach((ticketInfo: ITicketInfoModel) => { // const { seatLabel, rowLabel, categoryLabel } = ticketInfo; // const seatDetail = `כיסא ${seatLabel} ושורה ${rowLabel}`; // seatDetails.push(seatDetail); // }); // } // }); // if (convertToString) { // return seatDetails.join("| "); // } // return seatDetails; // } import { UserEventClient } from "../src/userEvent"; describe("userEvents", () => { it("should extract seat details", () => { const userEvents = [ { ticketsInfo: [ { seatLabel: "1", rowLabel: "2", categoryLabel: "3", }, ], }, ]; const result = UserEventClient.extractSeatDetails(userEvents as any); expect(result).toEqual(["1 2, (3)"]); }); it("should extract seat details and convert to string", () => { const userEvents = [ { ticketsInfo: [ { seatLabel: "1", rowLabel: "2", categoryLabel: "3", }, { seatLabel: "2", rowLabel: "2", categoryLabel: "3", }, ], }, ]; const result = UserEventClient.extractSeatDetails(userEvents as any, true); expect(result).toEqual("1 2, (3) | 2 2, (3)"); }); it("should extract seat details and convert to string", () => { const userEvents = [ { ticketsInfo: [ { seatLabel: "כסא 14", rowLabel: "שורה 1", categoryLabel: "רגיל", }, ], }, ]; const result = UserEventClient.extractSeatDetails(userEvents as any, true); expect(result).toEqual("כסא 14 שורה 1, (רגיל)"); }); it("should extract seat details and convert to string", () => { const userEvents = [ { ticketsInfo: [ { seat: "1-14", }, ], }, ]; const result = UserEventClient.extractSeatDetails(userEvents as any, true); expect(result).toEqual("שורה-1 כסא-14, "); }); });