Adrià Vilanova MartÃnez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 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 sinon from 'sinon'; |
| 7 | import {ChopsSnackbar} from './chops-snackbar.js'; |
| 8 | |
| 9 | let element; |
| 10 | |
| 11 | describe('chops-snackbar', () => { |
| 12 | beforeEach(() => { |
| 13 | element = document.createElement('chops-snackbar'); |
| 14 | document.body.appendChild(element); |
| 15 | }); |
| 16 | |
| 17 | afterEach(() => { |
| 18 | document.body.removeChild(element); |
| 19 | }); |
| 20 | |
| 21 | it('initializes', () => { |
| 22 | assert.instanceOf(element, ChopsSnackbar); |
| 23 | }); |
| 24 | |
| 25 | it('dispatches close event on close click', async () => { |
| 26 | element.opened = true; |
| 27 | await element.updateComplete; |
| 28 | |
| 29 | const listener = sinon.stub(); |
| 30 | element.addEventListener('close', listener); |
| 31 | |
| 32 | element.shadowRoot.querySelector('button').click(); |
| 33 | |
| 34 | sinon.assert.calledOnce(listener); |
| 35 | }); |
| 36 | }); |