egroupware/api/js/etemplate/Et2Button/test/Et2Button.test.ts
nathan ef3848fd3c - Fix including everything just for a unit test
- Start of some tests for Et2Button
2021-08-25 11:32:15 -06:00

42 lines
912 B
TypeScript

/**
* Test file for Etemplate webComponent base widget Et2Box
*/
import {assert, fixture} from '@open-wc/testing';
import {Et2Button} from "../Et2Button";
import type {Et2Widget} from "../../Et2Widget";
import {html} from "lit-element";
import * as sinon from 'sinon';
describe("Button widget", () =>
{
// Reference to component under test
let element : Et2Button;
// Setup run before each test
beforeEach(async() =>
{
// Create an element to test with, and wait until it's ready
element = await fixture<Et2Button>(html`
<et2-button label="I'm a button"></et2-button>
`);
// Stub egw()
sinon.stub(element, "egw").returns({
tooltipUnbind: () => {}
});
});
// Make sure it works
it('is defined', () =>
{
assert.instanceOf(element, Et2Button);
});
it('has a label', () =>
{
element.set_label("Label set");
assert.equal(element.textContent, "Label set");
})
});