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 {SpQuerySQL} from "../../../dist/trace/component/SpQuerySQL.js" 18 19describe('SpQuerySQL Test', () => { 20 let spQuerySQL= new SpQuerySQL(); 21 22 it('SpQuerySQLTest01', function () { 23 expect(spQuerySQL.checkSupportSqlAbility()).toBeFalsy() 24 }); 25 26 it('SpQuerySQLTest02', function () { 27 expect(spQuerySQL.checkSafetySelectSql()).toBeTruthy() 28 }); 29 30 it('SpQuerySQLTest03', function () { 31 expect(spQuerySQL.getSelectSqlField()).toBe("") 32 }); 33 34 it('SpQuerySQLTest04', function () { 35 expect(spQuerySQL.getSelectSqlTableName()).not.toBeUndefined() 36 }); 37 38 it('SpQuerySQLTest05', function () { 39 expect(spQuerySQL.initDataElement()).toBeUndefined() 40 }); 41 42 it('SpQuerySQLTest06', function () { 43 spQuerySQL.statDataArray.length = 1 44 expect(spQuerySQL.initData()).toBeUndefined() 45 }); 46 47 it('SpQuerySQLTest07', function () { 48 expect(spQuerySQL.attributeChangedCallback()).toBeUndefined() 49 }); 50 51 it('SpQuerySQLTest08', function () { 52 expect(spQuerySQL.initHtml()).toMatchInlineSnapshot(` 53" 54 <style> 55 :host{ 56 width: 100%; 57 height: 100%; 58 font-size: 16px; 59 background-color: var(--dark-background5,#F6F6F6); 60 margin: 0; 61 padding: 0; 62 } 63 64 .sql-select{ 65 box-sizing: border-box; 66 width: 95%; 67 font-family: Helvetica,serif; 68 font-size: inherit; 69 color: var(--dark-color1,#212121); 70 text-align: left; 71 line-height: 1.2em; 72 font-weight: 400; 73 height: 3.2em; 74 margin-left: 10px; 75 resize: vertical; 76 border-width: 2px; 77 } 78 79 .query{ 80 display: flex; 81 flex-direction: column; 82 background-color: var(--dark-background5,#F6F6F6); 83 position: absolute; 84 top: 0; 85 bottom: 0; 86 left: 0; 87 right: 0; 88 } 89 90 .query-message{ 91 background-color: var(--dark-background3,#FFFFFF); 92 padding: 1% 2%; 93 margin: 2% 2.5% 0 2.5%; 94 border-radius: 16px; 95 width: 90%; 96 } 97 98 .request{ 99 display: flex; 100 flex-direction: column; 101 position: relative; 102 } 103 104 .response{ 105 flex-grow: 1; 106 margin-bottom: 1%; 107 display: flex; 108 flex-direction: column; 109 min-height: inherit; 110 max-height: 70vh; 111 } 112 113 #dataResult{ 114 flex-grow: 1; 115 overflow-y: auto; 116 overflow-x: visible; 117 margin-bottom: 1%; 118 border-radius: 16px; 119 } 120 121 p{ 122 display: table-cell; 123 padding: 7px 10px; 124 color: #999999; 125 font-size:0.875em; 126 line-height: 20px; 127 font-weight: 400; 128 text-align: left; 129 } 130 131 #response-json{ 132 margin-top: 20px; 133 background-color: var(--dark-background5,#F6F6F6); 134 margin-left: 10px; 135 flex-grow: 1; 136 scroll-y: visible; 137 } 138 139 .sql-select{ 140 background-color: var(--dark-background5, #F6F6F6); 141 } 142 143 /*Define the height, width and background of the scroll bar*/ 144 ::-webkit-scrollbar 145 { 146 width: 8px; 147 background-color: var(--dark-background3,#FFFFFF); 148 } 149 150 /*define slider*/ 151 ::-webkit-scrollbar-thumb 152 { 153 border-radius: 6px; 154 background-color: var(--dark-background7,rgba(0,0,0,0.1)); 155 } 156 157 .load-metric{ 158 width: 95%; 159 bottom: 0; 160 } 161 162 #copy-button{ 163 margin-right: 10%; 164 cursor:pointer 165 } 166 167 #close-button{ 168 margin-right: 5%; 169 cursor:pointer 170 } 171 172 .button-option{ 173 border-radius: 15px; 174 background-color: #0A59F7; 175 width: 120px; 176 height: 25px; 177 font-family: Helvetica-Bold; 178 color: var(--dark-background3,#FFFFFF); 179 text-align: center; 180 line-height: 20px; 181 font-weight: 400; 182 border:0 solid; 183 } 184 185 </style> 186 <div class=\\"query\\"> 187 <div class=\\"query-message request\\"> 188 <p class=\\"query_select\\">Enter query and press cmd/ctrl + Enter</p> 189 <textarea class=\\"sql-select\\"></textarea> 190 <lit-progress-bar class=\\"load-metric\\"></lit-progress-bar> 191 </div> 192 <div class=\\"query-message response\\"> 193 <div style=\\"display: flex;justify-content: space-between\\"> 194 <p class=\\"query_size\\">Query result - 0 counts</p> 195 <div style=\\"display: flex; align-items: center\\"> 196 <button id=\\"copy-button\\" class=\\"button-option\\">Copy as.tsv</button> 197 <button id=\\"close-button\\" class=\\"button-option\\">Close</button> 198 </div> 199 </div> 200 <div id=\\"dataResult\\"></div> 201 </div> 202 </div> 203 " 204`); 205 }); 206 207 it('SpQuerySQLTest09', function () { 208 expect(spQuerySQL.initDataTableStyle({children:[{length:3,style:{backgroundColor:'var(--dark-background5,#F6F6F6)'}}]})).toBeUndefined() 209 }); 210 211 it('SpQuerySQLTest010', function () { 212 expect(spQuerySQL.freshTableHeadResizeStyle()).toBeUndefined(); 213 }); 214 215 it('SpQuerySQLTest011', function () { 216 expect(spQuerySQL.reset()).toBeUndefined(); 217 }); 218 219 it('SpQuerySQLTest012', function () { 220 let spQuerySQL =new SpQuerySQL(); 221 expect(spQuerySQL.initDataTableStyle({children: 222 [{length:1,style:{backgroundColor:'var(--dark-background5,#F6F6F6)'}}] 223 })).toBeUndefined() 224 }); 225 226 it('SpQuerySQLTest013', function () { 227 expect(spQuerySQL.initDataElement()).toBeUndefined(); 228 }); 229 230 it('SpQuerySQLTest014', function () { 231 expect(spQuerySQL.connectedCallback()).toBeUndefined(); 232 }); 233 234 it('SpQuerySQLTest015', function () { 235 expect(spQuerySQL.disconnectedCallback()).toBeUndefined(); 236 }); 237 238 it('SpQuerySQLTest016', function () { 239 expect(spQuerySQL.initData()).toBeUndefined(); 240 }); 241 242 it('SpQuerySQLTest017', function () { 243 expect(spQuerySQL.attributeChangedCallback('','','')).toBeUndefined(); 244 }); 245 246})