import BlacklistItemMapper from "../resources/blacklistItem/mapper"; import {IBlacklistItem} from "../resources/blacklistItem/index"; describe("BlacklistItemMapper", () => { it("should map an blacklist item to a blacklist item model", () => { const mapper = new BlacklistItemMapper(); const model: IBlacklistItem = mapper.toModel({ "type": "blacklist-item", "relationships": {}, "id": "0100322a-5e5f-11e8-8ba0-db1638c712d6", "attributes": { "created_at": "2018-05-23T10:46:56.337288", "updated_at": "2018-05-23T10:46:56.337288" } }); expect(model.id).toBe("0100322a-5e5f-11e8-8ba0-db1638c712d6"); expect(model.createdAt).toBe("2018-05-23T10:46:56.337288"); expect(model.updatedAt).toBe("2018-05-23T10:46:56.337288"); }); it("properly assigns target to the a blacklist item model", () => { const mapper = new BlacklistItemMapper(); const model: IBlacklistItem = mapper.toModel({ "type": "blacklist-item", "relationships": { "target": { "data": { id: "1234", type: "poi" } } }, "id": "0100322a-5e5f-11e8-8ba0-db1638c712d6", "attributes": { "created_at": "2018-05-23T10:46:56.337288", "updated_at": "2018-05-23T10:46:56.337288", } }, ([{ type: "poi", id: "1234", attributes: { name: "my POI" }, relationships: { "containing-place": { data: { type: "place", id: "362228" } } } }] as any)); expect(model.target.id).toBe("1234"); expect(model.target.type).toBe("poi"); }); });