Skip to content

Commit

Permalink
Widget: adding unit test for tab setting
Browse files Browse the repository at this point in the history
  • Loading branch information
gusthoff committed Sep 29, 2023
1 parent 61329eb commit 33de436
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions frontend/tests/ts/widget.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,11 @@ describe('Widget', () => {
});

describe('Settings Bar', () => {
let editorDiv: HTMLElement;
let editor: ace.Editor;

before(() => {
const editorDiv = getElemById(root.id + '.editors.editor');
editorDiv = getElemById(root.id + '.editors.editor');
editor = ace.edit(editorDiv);
});

Expand All @@ -413,9 +414,25 @@ describe('Widget', () => {
});

it('should have a checkbox that switches tab setting', () => {
// const box = getElemById(root.id + '.settings-bar.tab-setting') as
// HTMLInputElement;
// expect.fail('Test not implemented.');
const nonTabbedEditorDiv: HTMLElement = getElemById(root.id + '.editors.non-tabbed-editor');
const box = getElemById(root.id + '.settings-bar.tab-setting') as
HTMLInputElement;

const origIsTabbedView : boolean = !editorDiv.hidden;
expect(nonTabbedEditorDiv.hidden).to.equal(origIsTabbedView);

box.checked = !box.checked;
triggerEvent(box, 'change');
expect(editorDiv.hidden).to.equal(origIsTabbedView);
expect(nonTabbedEditorDiv.hidden).to.not.equal(origIsTabbedView);

// Test hiding / showing buttons for tabbed view
const tabs = getElemById(root.id + '.tab');
const headers = getElemsByTag(tabs, 'button');

for (const h of headers) {
expect(h.hidden).to.equal(origIsTabbedView);
}
});

it('should have a button that resets the editor', () => {
Expand Down

0 comments on commit 33de436

Please sign in to comment.