blob: 9e0416c9a13b0cb7c453e120c256a2ba3dd7b27e [file] [log] [blame]
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Test for <terminal-settings-row>
*/
import './terminal_settings_row.js';
describe('terminal_settings_row_tests.js', () => {
beforeEach(async function() {
this.expandableRow = document.createElement('terminal-settings-row');
this.expandableRow.setAttribute('expandable', '');
document.body.appendChild(this.expandableRow);
this.expandEvents = [];
this.expandableRow.addEventListener('expand', (e) => {
this.expandEvents.push(e);
});
await this.expandableRow.updateComplete;
});
afterEach(function() {
document.body.removeChild(this.expandableRow);
});
it('toggle expand state when clicked', async function() {
const main = this.expandableRow.shadowRoot.querySelector('#main');
assert.isFalse(this.expandableRow.expanded_);
main.click();
await this.expandableRow.updateComplete;
assert.isTrue(this.expandableRow.expanded_);
assert.equal(this.expandEvents.length, 1);
assert.equal(this.expandEvents[0].detail, true);
main.click();
await this.expandableRow.updateComplete;
assert.isFalse(this.expandableRow.expanded_);
assert.equal(this.expandEvents.length, 2);
assert.equal(this.expandEvents[1].detail, false);
});
});