blob: 70b9b54936b82cf01a94d3f562f8adc506548963 [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 sinon from 'sinon';
6import {assert} from 'chai';
7import {MrModeSelector} from './mr-mode-selector.js';
8
9let element;
10
11describe('mr-mode-selector', () => {
12 beforeEach(() => {
13 element = document.createElement('mr-mode-selector');
14 document.body.appendChild(element);
15
16 element._page = sinon.stub();
17 });
18
19 afterEach(() => {
20 document.body.removeChild(element);
21 });
22
23 it('initializes', () => {
24 assert.instanceOf(element, MrModeSelector);
25 });
26
27 it('renders links with projectName and queryParams', async () => {
28 element.value = 'list';
29 element.projectName = 'chromium';
30 element.queryParams = {q: 'hello-world'};
31
32 await element.updateComplete;
33
34 const links = element.shadowRoot.querySelectorAll('a');
35
36 assert.include(links[0].href, '/p/chromium/issues/list?q=hello-world');
37 assert.include(links[1].href,
38 '/p/chromium/issues/list?q=hello-world&mode=grid');
39 assert.include(links[2].href,
40 '/p/chromium/issues/list?q=hello-world&mode=chart');
41 });
42});