blob: 28d23eb57815f0e395882d39f7442fd89845675d [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 {MrIssueSlo} from './mr-issue-slo.js';
7
8
9let element;
10
11describe('mr-issue-slo', () => {
12 beforeEach(() => {
13 element = document.createElement('mr-issue-slo');
14 document.body.appendChild(element);
15 });
16
17 afterEach(() => {
18 document.body.removeChild(element);
19 });
20
21 it('initializes', () => {
22 assert.instanceOf(element, MrIssueSlo);
23 });
24
25 it('handles ineligible issues', async () => {
26 element._determineSloStatus = () => {
27 return null;
28 };
29 element.issue = {};
30 await element.updateComplete;
31 assert.equal(element.shadowRoot.textContent, 'N/A');
32 });
33
34 it('handles issues that have completed the SLO criteria', async () => {
35 element._determineSloStatus = () => {
36 return {target: null};
37 };
38 element.issue = {};
39 await element.updateComplete;
40 assert.equal(element.shadowRoot.textContent, 'Done');
41 });
42
43 it('handles issues that have not completed the SLO criteria', async () => {
44 element._determineSloStatus = () => {
45 return {target: 1234};
46 };
47 element.issue = {};
48 await element.updateComplete;
49 const timestampElement =
50 element.shadowRoot.querySelector('chops-timestamp');
51
52 assert.equal(timestampElement.timestamp, 1234);
53 });
54});