Skip to content

Commit

Permalink
chore: Add a unit test for valid URL generation (#800)
Browse files Browse the repository at this point in the history
* update examples and minimize URLs

* fix: add unit test for valid URL generation
  • Loading branch information
chrisjshull committed Jun 6, 2023
1 parent 743dd02 commit 9a13708
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ test("setScript does not add second script with same id", async () => {
expect(document.head.childNodes.length).toBe(1);
});

test("setScript adds a script to head with valid src", async () => {
const loader = new Loader({ apiKey: "foo" });

loader["setScript"]();
await 0;

const script = document.head.childNodes[0] as HTMLScriptElement;

expect(script.src).toEqual(
"https://maps.googleapis.com/maps/api/js?libraries=&key=foo&callback=google.maps.__ib__"
);
});

test("load should return a promise that resolves even if called twice", () => {
const loader = new Loader({ apiKey: "foo" });
loader.importLibrary = (() => Promise.resolve()) as any;
Expand Down

0 comments on commit 9a13708

Please sign in to comment.