import BookmarkMapper from "../resources/bookmark/bookmarkMapper"; import { IPoi } from "../resources/poi"; describe("BookmarkMapper", () => { it("should map a bookmark entry to a bookmark model", () => { const mapper = new BookmarkMapper(); const now = new Date().getTime(); const model = mapper.toModel({ type: "bookmark-entry", id: "1234", attributes: { checked: true, order_number: 1, created_at: now.toString(), note: "I love bookmarks" }, relationships: { target: { data: { type: "poi", id: "1234" } } }, }, [{ type: "poi", id: "1234", attributes: { name: "my POI" }, relationships: { "containing-place": { data: { type: "place", id: "362228" } } } }, { type: "place", id: "362228", attributes: { name: "Nashville" }, relationships: { ancestry: { data: [{ type: "place", id: "9999" }] } } }]); expect(model.order).toEqual(1); expect(model.checked).toBeTruthy; expect(model.createdAt instanceof Date).toBeTruthy(); expect(model.note).toEqual("I love bookmarks"); expect((model.target).name).toBe("my POI"); expect((model.target).containingPlaceId).toBe("362228"); expect((model.target).containingPlaceName).toBe("Nashville"); }); });