mercredi 19 février 2020

Test element color on focus

I'm want to write a test that checks the color of a material design text field label when has focus:

enter image description here

This is how I'm trying to do:

    it("has primary color label when focused", async () => {
        const el = await fixture<TextField>(
            html`
                <text-field label="Hello"></text-field>
            `,
        );

        const input = getInputElement(el);
        await triggerFocusFor(input);
        const floatingLabel = getFloatingLabel(el);
        const floatingLabelColor = getComputedStyleValue(floatingLabel, "color");

        expect(floatingLabelColor).equal(primaryColor);
    });

The test fails because the color of the label that I get is gray instead of the primary color. The components is made with LitElement and I'm testing with open @open-wc/testing.

Aucun commentaire:

Enregistrer un commentaire