import AvailabilityMapper from "../resources/availability/mapper"; describe("AvailabilityMapper", () => { it("should map a Availability entry to a Availability model", () => { const mapper = new AvailabilityMapper(); const model = mapper.toModel({ type: "availability", relationships: { lodging: { links: { related: "/lodgings/bab0a3a2-7135-4c9f-8434-75c61a7b8113" }, data: { type: "lodging", id: "bab0a3a2-7135-4c9f-8434-75c61a7b8113" } } }, id: "booking_dot_com,2021271,2018-07-27,2018-07-30", attributes: { provider: "booking_dot_com", offerings: [ { max_occupancy: null, description: { short: "", long: "" }, cost: { currency: "USD", amount: 877 } }, { max_occupancy: null, description: { short: "", long: "" }, cost: { currency: "USD", amount: 977 } } ], available: { to: "2018-07-30", from: "2018-07-27" } } }); expect(model.id).toEqual("booking_dot_com,2021271,2018-07-27,2018-07-30"); expect(model.available).toEqual({ to: "2018-07-30", from: "2018-07-27" }); expect(model.provider).toEqual("booking_dot_com"); expect(model.type).toEqual("availability"); expect(model.offerings).toEqual([ { maxOccupancy: null, description: { short: "", long: "" }, cost: { currency: "USD", amount: 877 } }, { maxOccupancy: null, description: { short: "", long: "" }, cost: { currency: "USD", amount: 977 } } ]); }); });