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