|
| 1 | +import * as L from "leaflet"; |
| 2 | +import * as PIXI from "pixi.js"; |
| 3 | +import { describe, expect, it, vitest } from "vitest"; |
| 4 | + |
| 5 | +import { register } from "./index.js"; |
| 6 | + |
| 7 | +describe("register()", () => { |
| 8 | + it("registers the plugin", () => { |
| 9 | + expect(register).toBeInstanceOf(Function); |
| 10 | + expect(L.pixiLetLayer).toBeUndefined(); |
| 11 | + expect(L.PixiLetLayer).toBeUndefined(); |
| 12 | + |
| 13 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-var-requires, unicorn/prefer-module |
| 14 | + register(require("leaflet"), require("pixi.js")); |
| 15 | + |
| 16 | + expect(L.pixiLetLayer).toBeInstanceOf(Function); |
| 17 | + expect(L.PixiLetLayer).toBeDefined(); |
| 18 | + }); |
| 19 | + |
| 20 | + describe("pixiLetLayer()", () => { |
| 21 | + it.todo("returns a new PixiLetLayer", () => { |
| 22 | + expect(L.pixiLetLayer).toBeInstanceOf(Function); |
| 23 | + expect(L.pixiLetLayer(() => { /* test */ })).toBeInstanceOf(L.PixiLetLayer); |
| 24 | + const spy = vitest.fn(), |
| 25 | + container = new PIXI.Container(), |
| 26 | + layer = L.pixiLetLayer(spy, { |
| 27 | + container, |
| 28 | + padding: 1, |
| 29 | + }); |
| 30 | + expect(layer).toBeInstanceOf(L.PixiLetLayer); |
| 31 | + expect(spy).not.toHaveBeenCalled(); |
| 32 | + expect(layer.options.padding).toBe(1); |
| 33 | + |
| 34 | + const map = L.map(document.createElement("div")).setView([51.505, -0.09], 13); |
| 35 | + expect(map.hasLayer(layer)).toBe(false); |
| 36 | + expect(layer.addTo(map)).toBe(layer); |
| 37 | + expect(map.hasLayer(layer)).toBe(true); |
| 38 | + expect(spy).toHaveBeenCalled(); |
| 39 | + }); |
| 40 | + }); |
| 41 | + |
| 42 | + describe.todo("new PixiLetLayer()", () => { |
| 43 | + it.todo("creates a new PixiLetLayer", () => { |
| 44 | + // TODO |
| 45 | + }); |
| 46 | + |
| 47 | + it.todo("sets the options", () => { |
| 48 | + // TODO |
| 49 | + }); |
| 50 | + }); |
| 51 | +}); |
0 commit comments