import imgix from "../utils/imgix"; describe("imgix utility", () => { it("should replace booking.com image URL", () => { const url = imgix("http://aff.bstatic.com/image.jpg", "bdc"); expect(url).toEqual("https://lpbookingcom.imgix.net/image.jpg"); }); it("should not replace booking.com image URL because wrong/missing provider", () => { const url = imgix("http://aff.bstatic.com/image.jpg"); expect(url).toEqual("http://aff.bstatic.com/image.jpg"); }); it("should replace G Adventures image URL", () => { const url = imgix("https://media.gadventures.com/image.jpg", "gadventures"); expect(url).toEqual("https://lpgadventures.imgix.net/image.jpg"); }); it("should replace HostelWorld image URL", () => { const url = imgix("http://ucd.hwstatic.com/image.jpg", "hw"); expect(url).toEqual("https://lphostelworld.imgix.net/image.jpg"); }); it("should replace media.lonelyplanet.com image URL", () => { const url = imgix("https://media.lonelyplanet.com/image.jpg", "media"); expect(url).toEqual("https://lonelyplanetimages.imgix.net/image.jpg"); }); it("should replace Viator image URL", () => { const url = imgix("http://cache-graphicslib.viator.com/image.jpg", "viator"); expect(url).toEqual("https://lpviator.imgix.net/image.jpg"); }); it("should replace media.lonelyplanet.com image URL by default with no provider", () => { const url = imgix("https://media.lonelyplanet.com/image.jpg"); expect(url).toEqual("https://lonelyplanetimages.imgix.net/image.jpg"); }); it("should return the same url if the provider is null", () => { const url = imgix("https://d9nqu5ycnl5tw.cloudfront.net/data/68/tour_964/xm-1.jpeg", null); expect(url).toEqual("https://d9nqu5ycnl5tw.cloudfront.net/data/68/tour_964/xm-1.jpeg"); }); it("should return the same url if the provider does not exist", () => { const url = imgix("https://d9nqu5ycnl5tw.cloudfront.net/data/68/tour_964/xm-1.jpeg", "urban_adventures"); expect(url).toEqual("https://d9nqu5ycnl5tw.cloudfront.net/data/68/tour_964/xm-1.jpeg"); }); });