"use strict";
var _resolveUrl = require("./resolve-url");
// required to be resolved as URL with resolveUrl()
describe("metadata: resolveUrl", ()=>{
    it("should return null when url is falsy", ()=>{
        expect((0, _resolveUrl).resolveUrl("", null)).toBe(null);
        expect((0, _resolveUrl).resolveUrl(null, null)).toBe(null);
        expect((0, _resolveUrl).resolveUrl(undefined, null)).toBe(null);
    });
    it("should error when metadataBase is not provided but url is not valid URL", ()=>{
        expect(()=>(0, _resolveUrl).resolveUrl("/abc", null)).toThrow("missing metadataBase");
    });
    it("should return url itself when metadataBase is null or url is valid URL", ()=>{
        expect((0, _resolveUrl).resolveUrl("https://example.com/abc", null)).toEqual(new URL("https://example.com/abc"));
        expect((0, _resolveUrl).resolveUrl(new URL("https://example.com/def"), null)).toEqual(new URL("https://example.com/def"));
    });
    it("should compose with metadataBase when url is relative or absolute", ()=>{
        const metadataBase = new URL("https://example.com/abc");
        expect((0, _resolveUrl).resolveUrl("/def", metadataBase)).toEqual(new URL("https://example.com/abc/def"));
        expect((0, _resolveUrl).resolveUrl("../def", metadataBase)).toEqual(new URL("https://example.com/def"));
        expect((0, _resolveUrl).resolveUrl("foo", metadataBase)).toEqual(new URL("https://example.com/abc/foo"));
    });
    it("should ignore metadataBase when url is valid URL", ()=>{
        const metadataBase = new URL("https://example.com/abc");
        expect((0, _resolveUrl).resolveUrl("https://example.com/def", metadataBase)).toEqual(new URL("https://example.com/def"));
        expect((0, _resolveUrl).resolveUrl(new URL("https://bar.com/ghi"), metadataBase)).toEqual(new URL("https://bar.com/ghi"));
    });
});

//# sourceMappingURL=resolve-url.test.js.map