From 71a9b21472b60a70afef6469815382893eac3fe4 Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Thu, 14 Oct 2021 13:54:16 +0200 Subject: [PATCH] temp --- tests/components/style_class.test.ts | 36 +++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/components/style_class.test.ts b/tests/components/style_class.test.ts index 9a89fe91..d646d2f1 100644 --- a/tests/components/style_class.test.ts +++ b/tests/components/style_class.test.ts @@ -1,4 +1,4 @@ -import { Component, mount, useState, xml } from "../../src"; +import { Component, mount, useState, useRef, xml } from "../../src"; import { makeTestFixture, nextTick, snapshotEverything } from "../helpers"; snapshotEverything(); @@ -234,4 +234,38 @@ describe("style and class handling", () => { await nextTick(); expect(span.className).toBe("c b d"); }); + + test("t-att-class is properly added/removed on widget root el (v3)", async () => { + + class Child extends Component { + static template = ``; + state = useState({ d: true }); + } + class Parent extends Component { + static template = xml`` + static components = { Child }; + state = useState({ b: true }); + child = useRef("child"); + } + const widget = await mount(Parent, fixture); + + const span = fixture.querySelector("span")!; + expect(span.className).toBe("c d a b"); + + widget.state.b = false; + await nextTick(); + expect(span.className).toBe("c d a"); + + (widget.child.comp as Child).state.d = false; + await nextTick(); + expect(span.className).toBe("c a"); + + widget.state.b = true; + await nextTick(); + expect(span.className).toBe("c a b"); + + (widget.child.comp as Child).state.d = true; + await nextTick(); + expect(span.className).toBe("c a b d"); + }); });