Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | import {assert} from 'chai'; |
| 6 | import {ChopsButton} from './chops-button.js'; |
| 7 | import {auditA11y} from 'shared/test/helpers'; |
| 8 | |
| 9 | let element; |
| 10 | |
| 11 | describe('chops-button', () => { |
| 12 | beforeEach(() => { |
| 13 | element = document.createElement('chops-button'); |
| 14 | document.body.appendChild(element); |
| 15 | }); |
| 16 | |
| 17 | afterEach(() => { |
| 18 | document.body.removeChild(element); |
| 19 | }); |
| 20 | |
| 21 | it('initializes', () => { |
| 22 | assert.instanceOf(element, ChopsButton); |
| 23 | }); |
| 24 | |
| 25 | it('initial a11y', async () => { |
| 26 | const text = document.createTextNode('button text'); |
| 27 | element.appendChild(text); |
| 28 | await auditA11y(element); |
| 29 | }); |
| 30 | |
| 31 | it('chops-button can be disabled', async () => { |
| 32 | await element.updateComplete; |
| 33 | |
| 34 | const innerButton = element.shadowRoot.querySelector('button'); |
| 35 | |
| 36 | assert.isFalse(element.hasAttribute('disabled')); |
| 37 | assert.isFalse(innerButton.hasAttribute('disabled')); |
| 38 | |
| 39 | element.disabled = true; |
| 40 | await element.updateComplete; |
| 41 | |
| 42 | assert.isTrue(element.hasAttribute('disabled')); |
| 43 | assert.isTrue(innerButton.hasAttribute('disabled')); |
| 44 | }); |
| 45 | }); |