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 16jest.mock('../../../dist/trace/component/trace/base/TraceRow.js', () => { 17 return {}; 18}); 19 20// @ts-ignore 21import { JsCpuProfilerUIStruct, JsCpuProfilerChartFrame, JsCpuProfilerTabStruct, JsCpuProfilerStatisticsStruct } from '../../../dist/trace/bean/JsStruct.js'; 22 23describe('JsStruct Test', () => { 24 let jsCpuProfilerUIStruct = new JsCpuProfilerUIStruct(); 25 let jsCpuProfilerChartFrame = new JsCpuProfilerChartFrame(); 26 let jsCpuProfilerTabStruct = new JsCpuProfilerTabStruct(); 27 let jsCpuProfilerStatisticsStruct = new JsCpuProfilerStatisticsStruct(); 28 29 it('JsCpuProfilerUIStructTest01', function () { 30 jsCpuProfilerUIStruct = { 31 name: '', 32 depth: 0, 33 selfTime: 0, 34 totalTime: 0, 35 url:'', 36 line: 0, 37 column: 0, 38 scriptName: '', 39 id: 0, 40 parentId: 0, 41 } 42 expect(jsCpuProfilerUIStruct).not.toBeUndefined(); 43 expect(jsCpuProfilerUIStruct).toMatchInlineSnapshot(` 44{ 45 "column": 0, 46 "depth": 0, 47 "id": 0, 48 "line": 0, 49 "name": "", 50 "parentId": 0, 51 "scriptName": "", 52 "selfTime": 0, 53 "totalTime": 0, 54 "url": "", 55} 56`); 57 }); 58 it('JsCpuProfilerChartFrameTest02', function () { 59 jsCpuProfilerChartFrame = { 60 name: '', 61 depth: 0, 62 selfTime: 0, 63 totalTime: 0, 64 url:'', 65 line: 0, 66 column: 0, 67 scriptName: '', 68 id: 0, 69 parentId: 0, 70 startTime: 0, 71 endTime: 0, 72 children: [], 73 samplesIds: [], 74 isSelect: false, 75 } 76 expect(jsCpuProfilerChartFrame).not.toBeUndefined(); 77 expect(jsCpuProfilerChartFrame).toMatchInlineSnapshot(` 78{ 79 "children": [], 80 "column": 0, 81 "depth": 0, 82 "endTime": 0, 83 "id": 0, 84 "isSelect": false, 85 "line": 0, 86 "name": "", 87 "parentId": 0, 88 "samplesIds": [], 89 "scriptName": "", 90 "selfTime": 0, 91 "startTime": 0, 92 "totalTime": 0, 93 "url": "", 94} 95`); 96 }); 97 it('JsCpuProfilerTabStructTest02', function () { 98 jsCpuProfilerTabStruct = { 99 name: '', 100 depth: 0, 101 selfTime: 0, 102 totalTime: 0, 103 url:'', 104 line: 0, 105 column: 0, 106 scriptName: '', 107 id: 0, 108 parentId: 0, 109 children:[], 110 chartFrameChildren: [], 111 isSelected: false, 112 totalTimePercent: '', 113 selfTimePercent: '', 114 symbolName: '', 115 selfTimeStr: '', 116 totalTimeStr:'', 117 isSearch: false 118 } 119 expect(jsCpuProfilerTabStruct).not.toBeUndefined(); 120 expect(jsCpuProfilerTabStruct).toMatchInlineSnapshot(` 121{ 122 "chartFrameChildren": [], 123 "children": [], 124 "column": 0, 125 "depth": 0, 126 "id": 0, 127 "isSearch": false, 128 "isSelected": false, 129 "line": 0, 130 "name": "", 131 "parentId": 0, 132 "scriptName": "", 133 "selfTime": 0, 134 "selfTimePercent": "", 135 "selfTimeStr": "", 136 "symbolName": "", 137 "totalTime": 0, 138 "totalTimePercent": "", 139 "totalTimeStr": "", 140 "url": "", 141} 142`); 143 }); 144 it('JsCpuProfilerStatisticsStructTest02', function () { 145 jsCpuProfilerStatisticsStruct = { 146 type: '', 147 time: 0, 148 timeStr: '', 149 percentage: '' 150 } 151 expect(jsCpuProfilerStatisticsStruct).not.toBeUndefined(); 152 expect(jsCpuProfilerStatisticsStruct).toMatchInlineSnapshot(` 153{ 154 "percentage": "", 155 "time": 0, 156 "timeStr": "", 157 "type": "", 158} 159`); 160 }); 161}); 162