blob: fa45d68751a8e920b8b379a1e80d8e197c9e9771 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001// 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
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});