1/* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16// @ts-ignore 17import {SpMetrics} from "../../../dist/trace/component/SpMetrics.js" 18 19describe('SpMetrics Test', () => { 20 let spMetrics = new SpMetrics(); 21 it('SpMetricsTest01', function () { 22 expect(SpMetrics.initElements).toBeUndefined() 23 }); 24 it('SpMetricsTest02', function () { 25 expect(spMetrics.metric).toBe("") 26 }); 27 it('SpMetricsTest03', function () { 28 spMetrics.metric = true; 29 expect(spMetrics.metric).toBe("") 30 }); 31 it('SpMetricsTest04', function () { 32 expect(spMetrics.metricResult).toBe("") 33 34 }); 35 it('SpMetricsTest05', function () { 36 spMetrics.metricResult = true; 37 expect(spMetrics.metricResult).toBeTruthy() 38 }); 39 40 it('SpMetricsTest06', function () { 41 expect(spMetrics.attributeChangedCallback("metric")).toBeUndefined() 42 }); 43 44 it('SpMetricsTest07', function () { 45 expect(spMetrics.attributeChangedCallback("metricResult")).toBeUndefined() 46 }); 47 48 it('SpMetricsTest08', function () { 49 expect(spMetrics.initHtml()).toMatchInlineSnapshot(` 50" 51 <style> 52 53 :host{ 54 width: 100%; 55 height: 100%; 56 background-color: var(--dark-background5,#F6F6F6); 57 margin: 0; 58 padding: 0; 59 font-size:16px; 60 } 61 62 .metric{ 63 display: flex; 64 flex-direction: column; 65 position: absolute; 66 top: 0; 67 bottom: 0; 68 left: 0; 69 right: 0; 70 background-color: var(--dark-background5,#F6F6F6); 71 } 72 73 .metric-select{ 74 color: #121212; 75 border-radius: 16px; 76 background-color: var(--dark-background3,#FFFFFF); 77 padding: 1% 2%; 78 margin: 2% 2.5% 0 2.5%; 79 grid-row-gap: 30px; 80 } 81 82 .request{ 83 min-height: 15vh; 84 overflow: auto; 85 position: relative; 86 } 87 88 .sql-select{ 89 font-family: Helvetica,serif; 90 color: var(--dark-color1,#212121); 91 font-size:0.875em; 92 line-height: 16px; 93 font-weight: 400; 94 text-align: left; 95 width: 50%; 96 height: 32px; 97 flex-wrap: wrap; 98 margin-top: 1%; 99 border: 1px solid var(--dark-color1,#4D4D4D); 100 border-radius: 16px; 101 padding: 5px 10px 5px 10px; 102 -webkit-appearance: none; 103 background: url('img/down.png') no-repeat 98% center; 104 } 105 106 button{ 107 border-radius: 16px; 108 flex-grow: 1; 109 background-color: #0A59F7; 110 height: 32px; 111 width: 96px; 112 font-size: 0.875em; 113 color: var(--dark-background3,#FFFFFF); 114 text-align: center; 115 line-height: 20px; 116 font-weight: 400; 117 border:0 solid; 118 margin-left: 2%; 119 } 120 121 .response{ 122 flex-grow: 1; 123 margin-bottom: 1%; 124 } 125 126 .response-json{ 127 background-color: var(--dark-background3,#FFFFFF); 128 border-radius: 16px; 129 display: table-cell; 130 font-family: Helvetica,serif; 131 color: var(--dark-color1,#212121); 132 font-size:0.875em; 133 line-height: 20px; 134 font-weight: 400; 135 text-align: left; 136 height: 90%; 137 width: 100%; 138 border: none; 139 outline:none; 140 resize:none; 141 } 142 143 p{ 144 display: table-cell; 145 padding: 20% 0; 146 color: #999999; 147 font-size:0.875em; 148 line-height: 20px; 149 font-weight: 400; 150 text-align: left; 151 width: 100%; 152 } 153 154 /*Define scroll bar height, width and background*/ 155 ::-webkit-scrollbar 156 { 157 width: 8px; 158 background-color: var(--dark-background3,#FFFFFF); 159 } 160 161 /*define slider*/ 162 ::-webkit-scrollbar-thumb 163 { 164 border-radius: 6px; 165 background-color: var(--dark-background7,rgba(0,0,0,0.1)); 166 } 167 168 .load-metric{ 169 width: 95%; 170 bottom: 0; 171 } 172 173 </style> 174 175 <div class=\\"metric\\"> 176 <div class=\\"metric-select request\\"> 177 <p>Select a metric</p> 178 <select class=\\"sql-select\\"> 179 </select> 180 <button class=\\"sql-select-button\\"> Run </button> 181 <lit-progress-bar class=\\"load-metric\\"></lit-progress-bar> 182 </div> 183 <div class=\\"metric-select response\\"> 184 <textarea class=\\"response-json\\" readonly> 185 </textarea> 186 </div> 187 </div> 188 " 189`); 190 }); 191 192 it('SpMetricsTest09', function () { 193 expect(spMetrics.reset()).toBeUndefined() 194 }); 195 196 it('SpMetricsTest10', function () { 197 expect(spMetrics.connectedCallback()).toBeUndefined(); 198 }); 199 200 it('SpMetricsTest11', function () { 201 expect(spMetrics.disconnectedCallback()).toBeUndefined(); 202 }); 203 204 it('SpMetricsTest12', function () { 205 expect(spMetrics.initMetricSelectOption()).toBeUndefined(); 206 }); 207 208 it('SpMetricsTest13', function () { 209 expect(spMetrics.initMetricDataHandle()).toBeUndefined(); 210 }); 211 212 213 214 215 216})