mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-26 18:03:39 +01:00
Add some tests for Et2Box.disabled to make sure it behaves.
This commit is contained in:
parent
19a2b13974
commit
a5f8b6076a
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Test file for Etemplate webComponent base widget Et2Box
|
||||
*/
|
||||
import {assert, fixture} from '@open-wc/testing';
|
||||
import {assert, elementUpdated, fixture} from '@open-wc/testing';
|
||||
import {Et2Box} from "../Et2Box";
|
||||
import {html} from "lit-element";
|
||||
|
||||
@ -28,5 +28,40 @@ describe("Box widget", () =>
|
||||
{
|
||||
element.set_label("Nope");
|
||||
assert.isEmpty(element.shadowRoot.querySelectorAll('.et2_label'));
|
||||
})
|
||||
});
|
||||
|
||||
it('disabled', async() =>
|
||||
{
|
||||
element.disabled = true;
|
||||
|
||||
// wait for asychronous changes to the DOM
|
||||
// @ts-ignore TypeScript is not recognizing that this widget is a LitElement
|
||||
await elementUpdated(element);
|
||||
|
||||
let style = window.getComputedStyle(<Element><unknown>element);
|
||||
assert.include(element.getAttributeNames(), "disabled", "Missing disabled attribute");
|
||||
assert.equal(style.display, "none", "Did not hide when disabled");
|
||||
|
||||
element.disabled = false;
|
||||
// wait for asychronous changes to the DOM
|
||||
// @ts-ignore TypeScript is not recognizing that this widget is a LitElement
|
||||
await elementUpdated(element);
|
||||
|
||||
// Check attribute goes
|
||||
assert.notInclude(element.getAttributeNames(), "disabled", "Still had disabled attribute after setting it to false");
|
||||
style = window.getComputedStyle(<Element><unknown>element);
|
||||
assert.notEqual(style.display, "none", "Did not show when not disabled");
|
||||
|
||||
/** Check via set method instead of property **/
|
||||
element.set_disabled(true);
|
||||
|
||||
// wait for asychronous changes to the DOM
|
||||
// @ts-ignore TypeScript is not recognizing that this widget is a LitElement
|
||||
await elementUpdated(element);
|
||||
style = window.getComputedStyle(<Element><unknown>element);
|
||||
assert.include(element.getAttributeNames(), "disabled", "Missing disabled attribute");
|
||||
assert.equal(style.display, "none", "Did not hide when disabled via set_disabled()");
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user