import AutocompleteMapper from "../resources/search/autocomplete/mapper"; describe("AutocompleteMapper", () => { it("should map a search result to an autocomplete model", () => { const mapper = new AutocompleteMapper(); const model = mapper.toModel({ type: "search-result", relationships: { target: { links: { related: "/places/360265" }, data: { type: "place", id: "360265" } } }, id: "1611e6f708c9e1a134b57c9688cdae54f4c38cdf", attributes: { url: "https://www.lonelyplanet.com/poland", title: "Poland", "op-id": "360265", "op-type": "place", highlights: { title: "Poland" }, body: null, "parent-name": "Europe", "place-type": "country", thumbnail: "images/thumbnail.png", } }); expect(model.id).toBe("1611e6f708c9e1a134b57c9688cdae54f4c38cdf"); expect(model.url).toBe("https://www.lonelyplanet.com/poland"); expect(model.title).toBe("Poland"); expect(model.opId).toBe("360265"); expect(model.opType).toBe("place"); expect(model.parentName).toBe("Europe"); expect(model.placeType).toBe("country"); expect(model.highlights.title).toBe("Poland"); expect(model.thumbnail).toBe("images/thumbnail.png"); }); });