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 {SpTraceCommand} from "../../../../dist/trace/component/setting/SpTraceCommand.js"; 18 19describe('SPTraceCommand Test', ()=>{ 20 beforeAll(() => { 21 document.body.innerHTML = ` 22 <trace-command id = "command"><trace-command> 23 ` 24 }) 25 it('new SPTraceCommand', function () { 26 expect(new SpTraceCommand()).not.toBeNull(); 27 }); 28 29 it(' SpAllocations get Default attrValue', function () { 30 let spEle = document.querySelector("#command") as SpTraceCommand 31 expect(spEle.hdcCommon).toEqual(""); 32 }); 33 34 it(' SpAllocations set attrValue', function () { 35 let spEle = document.querySelector("#command") as SpTraceCommand 36 spEle.hdcCommon = "test" 37 expect(spEle.hdcCommon).toEqual("test"); 38 }); 39 40 it(' SpTraceCommand test', function () { 41 let spEle = document.querySelector("#command") as SpTraceCommand 42 expect(spEle.initHtml()).toMatchInlineSnapshot(` 43" 44 <style> 45 :host{ 46 width: 100%; 47 position: relative; 48 background: var(--dark-background3,#FFFFFF); 49 border-radius: 0px 16px 16px 0px; 50 } 51 52 #code-text{ 53 -webkit-appearance:none; 54 opacity: 0.6; 55 font-family: Helvetica; 56 color: var(--dark-color,#000000); 57 padding: 20px 56px 5px 56px; 58 font-size:1em; 59 margin-left: 10px; 60 line-height: 20px; 61 font-weight: 400; 62 border: none; 63 outline:none; 64 resize:none; 65 /*overflow:auto;*/ 66 z-index: 2; 67 min-height: 500px; 68 background: var(--dark-background3,#FFFFFF); 69 } 70 71 #copy-image{ 72 display: table-cell; 73 white-space: nowrap; 74 outline:0; 75 float:right; 76 z-index: 66; 77 position: relative; 78 top: 56px; 79 right: 40px; 80 } 81 82 #copy-button{ 83 -webkit-appearance:none; 84 outline:0; 85 border: 0; 86 background: var(--dark-background3,#FFFFFF); 87 justify-content: end; 88 z-index: 55; 89 border-radius: 0px 16px 0px 0px; 90 } 91 92 #text-cmd{ 93 /*overflow-y:auto;*/ 94 display: grid; 95 justify-content: stretch; 96 align-content: stretch; 97 font-size:16px; 98 background: var(--dark-background3,#FFFFFF); 99 border-radius: 0px 16px 0px 0px; 100 101 } 102 103 /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/ 104 ::-webkit-scrollbar 105 { 106 width: 6px; 107 height: 10px; 108 background-color: var(--dark-background3,#FFFFFF); 109 } 110 111 /*定义滚动条轨道 内阴影+圆角*/ 112 ::-webkit-scrollbar-track 113 { 114 background-color: var(--dark-background3,#FFFFFF); 115 } 116 117 /*定义滑块 内阴影+圆角*/ 118 ::-webkit-scrollbar-thumb 119 { 120 border-radius: 6px; 121 background-color: var(--dark-background7,#e7c9c9); 122 } 123 124 #stop-button{ 125 display: none; 126 border-radius: 15px; 127 background-color: #0A59F7; 128 width: 120px; 129 height: 32px; 130 font-family: Helvetica-Bold; 131 font-size: 14px; 132 color: #FFFFFF; 133 text-align: center; 134 line-height: 20px; 135 margin-left: 80%; 136 border: 1px solid #FFFFFF; 137 } 138 139 :host([show]) #stop-button { 140 display: block 141 } 142 </style> 143 <div id=\\"text-cmd\\"> 144 <button id=\\"copy-button\\"> 145 <img id=\\"copy-image\\" src=\\"img/copy.png\\"> 146 </button> 147 <textarea id=\\"code-text\\" readonly></textarea> 148 <button id=\\"stop-button\\">Stop Cmd</button> 149 </div> 150 " 151`) 152 }); 153 it(' SpTraceCommandtest01', function () { 154 let spEle = document.querySelector("#command") as SpTraceCommand 155 spEle.show = false 156 expect(spEle.show).toBeFalsy() 157 }) 158 it(' SpTraceCommandtest02', function () { 159 let spEle = document.querySelector("#command") as SpTraceCommand 160 spEle.show = true 161 expect(spEle.show).toBeTruthy() 162 }) 163 it(' SpTraceCommandtest03', function () { 164 let spEle = document.querySelector("#command") as SpTraceCommand 165 expect(spEle.disconnectedCallback()).toBeUndefined() 166 }) 167})