import { test, expect } from "vitest" import { morph } from "../../src/morphlex" import { dom, observeMutations } from "./utils" test("insert item at the end of a list", () => { const from = dom(` `) const to = dom(` `) const expected = to.outerHTML const mutations = observeMutations(from, () => { morph(from, to) }) expect(from.outerHTML).toBe(expected) expect(mutations.elementsAdded).toBe(1) }) test("insert item at the beginning of a list", () => { const from = dom(` `) const to = dom(` `) const expected = to.outerHTML const mutations = observeMutations(from, () => { morph(from, to) }) expect(from.outerHTML).toBe(expected) expect(mutations.elementsAdded).toBe(1) }) test("insert item in the middle of a list", () => { const from = dom(` `) const to = dom(` `) const expected = to.outerHTML const mutations = observeMutations(from, () => { morph(from, to) }) expect(from.outerHTML).toBe(expected) expect(mutations.elementsAdded).toBe(1) })