blob: ee9450c18f99994b8a7d7585900ff18bfbf4453f [file] [log] [blame]
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +01001// Copyright 2019 The Chromium Authors
Copybara854996b2021-09-07 19:36:02 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import {assert} from 'chai';
6import sinon from 'sinon';
7import {ChopsSnackbar} from './chops-snackbar.js';
8
9let element;
10
11describe('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});