update to v2.2.1
fix type issues with root object wrapping node or querySelector fix incorrect import in demo fix unused options in vite.config.js add (some) tests - more to come!
This commit is contained in:
32
src/__tests__/fluent-dom-esm.test.ts
Normal file
32
src/__tests__/fluent-dom-esm.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import $d from "../fluent-dom-esm";
|
||||
|
||||
describe("fluent-dom-esm tests", () => {
|
||||
it("should allow for wrapping an existing node", () => {
|
||||
const $body = $d(document.body);
|
||||
$d(document.body).app($d.c("div").cls("test-class").t("text content"));
|
||||
expect($body.toDom()?.innerHTML).toEqual(
|
||||
'<div class="test-class">text content</div>',
|
||||
);
|
||||
expect(document.body?.innerHTML).toEqual(
|
||||
'<div class="test-class">text content</div>',
|
||||
);
|
||||
});
|
||||
|
||||
it("should allow for wrapping an existing node via a querySelector for an ID", () => {
|
||||
$d(document.body)
|
||||
.app($d.c("div").id("item1").t("Item 1"))
|
||||
.app($d.c("div").id("item2").t("Item 2"))
|
||||
.app($d.c("div").id("item3").cls("item-num3").t("Item 3"));
|
||||
expect($d("#item2").toDom()).toHaveTextContent("Item 2");
|
||||
expect($d("#item3").toDom()).toHaveClass("item-num3");
|
||||
});
|
||||
|
||||
it("should append text provided via `.text()`", () => {
|
||||
const testVal = "testing 123";
|
||||
expect($d.c("div").t(testVal).toDom()).toHaveTextContent(testVal);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user