blob: 78f70ee76dbeb9b81c9f22903148c87356536e91 [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 {EztAppBase} from './ezt-app-base.js';
8
9
10let element;
11
12describe('ezt-app-base', () => {
13 beforeEach(() => {
14 element = document.createElement('ezt-app-base');
15 document.body.appendChild(element);
16 });
17
18 afterEach(() => {
19 document.body.removeChild(element);
20 });
21
22 it('initializes', () => {
23 assert.instanceOf(element, EztAppBase);
24 });
25
26 it('fetches user data when userDisplayName set', async () => {
27 sinon.stub(element, 'fetchUserData');
28
29 element.userDisplayName = 'test@example.com';
30
31 await element.updateComplete;
32
33 sinon.assert.calledOnce(element.fetchUserData);
34 sinon.assert.calledWith(element.fetchUserData, 'test@example.com');
35 });
36
37 it('does not fetch data when userDisplayName is empty', async () => {
38 sinon.stub(element, 'fetchUserData');
39 element.userDisplayName = '';
40
41 await element.updateComplete;
42
43 sinon.assert.notCalled(element.fetchUserData);
44 });
45
46 it('fetches project data when projectName set', async () => {
47 sinon.stub(element, 'fetchProjectData');
48
49 element.projectName = 'chromium';
50
51 await element.updateComplete;
52
53 sinon.assert.calledOnce(element.fetchProjectData);
54 sinon.assert.calledWith(element.fetchProjectData, 'chromium');
55 });
56
57 it('does not fetch data when projectName is empty', async () => {
58 sinon.stub(element, 'fetchProjectData');
59 element.projectName = '';
60
61 await element.updateComplete;
62
63 sinon.assert.notCalled(element.fetchProjectData);
64 });
65});