|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 | 16 | /* eslint @typescript-eslint/no-explicit-any: 0 */
|
17 |
| -import { DEFAULT_ID, Loader, LoaderOptions } from "."; |
| 17 | +import { DEFAULT_ID, Loader, LoaderOptions, LoaderStatus } from "."; |
18 | 18 |
|
19 | 19 | jest.useFakeTimers();
|
20 | 20 |
|
@@ -54,6 +54,7 @@ test.each([
|
54 | 54 | ])("createUrl is correct", (options: LoaderOptions, expected: string) => {
|
55 | 55 | const loader = new Loader(options);
|
56 | 56 | expect(loader.createUrl()).toEqual(expected);
|
| 57 | + expect(loader.status).toBe(LoaderStatus.INITIALIZED); |
57 | 58 | });
|
58 | 59 |
|
59 | 60 | test("uses default id if empty string", () => {
|
@@ -128,6 +129,7 @@ test("script onerror should reject promise", async () => {
|
128 | 129 | expect(loader["done"]).toBeTruthy();
|
129 | 130 | expect(loader["loading"]).toBeFalsy();
|
130 | 131 | expect(loader["errors"].length).toBe(1);
|
| 132 | + expect(loader.status).toBe(LoaderStatus.FAILURE); |
131 | 133 | });
|
132 | 134 |
|
133 | 135 | test("script onerror should reject promise with multiple loaders", async () => {
|
@@ -301,6 +303,7 @@ test("singleton should be used", () => {
|
301 | 303 |
|
302 | 304 | loader["done"] = true;
|
303 | 305 | expect(extraLoader["done"]).toBe(loader["done"]);
|
| 306 | + expect(loader.status).toBe(LoaderStatus.SUCCESS); |
304 | 307 | });
|
305 | 308 |
|
306 | 309 | test("singleton should throw with different options", () => {
|
@@ -333,7 +336,7 @@ test("loader should resolve immediately when failed loading", async () => {
|
333 | 336 | test("loader should wait if already loading", () => {
|
334 | 337 | const loader = new Loader({ apiKey: "foo", retries: 0 });
|
335 | 338 | loader["loading"] = true;
|
336 |
| - |
| 339 | + expect(loader.status).toBe(LoaderStatus.LOADING); |
337 | 340 | loader.load();
|
338 | 341 | });
|
339 | 342 |
|
|
0 commit comments