Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | // Copyright 2020 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 {MrTabs} from './mr-tabs.js'; |
| 7 | |
| 8 | /** @type {MrTabs} */ |
| 9 | let element; |
| 10 | |
| 11 | describe('mr-tabs', () => { |
| 12 | beforeEach(() => { |
| 13 | // @ts-ignore |
| 14 | element = document.createElement('mr-tabs'); |
| 15 | document.body.appendChild(element); |
| 16 | }); |
| 17 | |
| 18 | afterEach(() => { |
| 19 | document.body.removeChild(element); |
| 20 | }); |
| 21 | |
| 22 | it('initializes', () => { |
| 23 | assert.instanceOf(element, MrTabs); |
| 24 | }); |
| 25 | |
| 26 | it('renders tabs', async () => { |
| 27 | element.items = [ |
| 28 | {text: 'Text 1'}, |
| 29 | {text: 'Text 2', icon: 'done', url: 'https://url'}, |
| 30 | ]; |
| 31 | element.selected = 1; |
| 32 | await element.updateComplete; |
| 33 | |
| 34 | const items = element.shadowRoot.querySelectorAll('li'); |
| 35 | assert.equal(items[0].className, ''); |
| 36 | assert.equal(items[1].className, 'selected'); |
| 37 | }); |
| 38 | }); |