From b52abb9b6270a097a823d9c53ba3fabc6935b480 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 4 Oct 2021 14:42:30 +0200 Subject: [PATCH] Implement a test for Colorpicker widget --- .../test/Et2Colorpicker.test.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 api/js/etemplate/Et2Colorpicker/test/Et2Colorpicker.test.ts diff --git a/api/js/etemplate/Et2Colorpicker/test/Et2Colorpicker.test.ts b/api/js/etemplate/Et2Colorpicker/test/Et2Colorpicker.test.ts new file mode 100644 index 0000000000..fc38aab413 --- /dev/null +++ b/api/js/etemplate/Et2Colorpicker/test/Et2Colorpicker.test.ts @@ -0,0 +1,38 @@ +/** + * Test file for Etemplate webComponent base widget Et2Colorpicker + */ +import {assert, fixture} from '@open-wc/testing'; +import {Et2Colorpicker} from "../Et2Colorpicker"; +import {html} from "lit-element"; + + +describe("Colorpicker widget", () => +{ + // Reference to component under test + let element : Et2Colorpicker; + + // Setup run before each test + beforeEach(async() => + { + // Create an element to test with, and wait until it's ready + element = await fixture(html` + + `); + }); + + it('is defined', () => + { + assert.instanceOf(element, Et2Colorpicker); + }); + + it('clearing value', () => + { + // set a value + element.set_value("11111"); + // trigger the clear button + element.__getClearButtonNode().dispatchEvent(new MouseEvent('click')); + + assert.equal(element.getValue(), ""); + }); + +}); \ No newline at end of file