import SearchMapper from "../resources/search/mapper"; describe("SearchMapper", () => { it("should map a search result to a search model", () => { const mapper = new SearchMapper(); 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: "Chic medieval hot spots like Kraków and Gdańsk vie with energetic Warsaw for your urban attention. Outside the cities, woods, rivers, lakes and hills beckon for some fresh-air fun.", "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.parentName).toBe("Europe"); expect(model.placeType).toBe("country"); expect(model.opId).toBe("360265"); expect(model.opType).toBe("place"); expect(model.highlights.title).toBe("Poland"); expect(model.body).toBe("Chic medieval hot spots like Kraków and Gdańsk vie with energetic Warsaw for your urban attention. Outside the cities, woods, rivers, lakes and hills beckon for some fresh-air fun."); expect(model.thumbnail).toBe("images/thumbnail.png"); }); });