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// @ts-ignore 16import { SpArkTsChart } from '../../../../dist/trace/component/chart/SpArkTsChart.js'; 17// @ts-ignore 18import { SpChartManager } from '../../../../dist/trace/component/chart/SpChartManager.js'; 19 20const sqlite = require('../../../../dist/trace/database/SqlLite.js'); 21jest.mock('../../../../dist/trace/database/SqlLite.js'); 22 23describe('SpClockChart Test', () => { 24 let arkTsChart = new SpArkTsChart(new SpChartManager()); 25 26 let jsCpuProfilerConfig = sqlite.queryJsCpuProfilerConfig; 27 let cpuProfilerConfigData = [ 28 { 29 enableCpuProfiler: 1, 30 pid: 1553, 31 type: -1, 32 }, 33 ]; 34 jsCpuProfilerConfig.mockResolvedValue(cpuProfilerConfigData); 35 36 let jsCpuProfiler = sqlite.queryJsCpuProfilerData; 37 let cpuProfilerData = [ 38 { 39 1: 1, 40 }, 41 ]; 42 jsCpuProfiler.mockResolvedValue(cpuProfilerData); 43 44 let jsMemory = sqlite.queryJsMemoryData; 45 let jsMemoryData = [{}]; 46 jsMemory.mockResolvedValue(jsMemoryData); 47 48 it('SpClockChart01', function () { 49 expect(arkTsChart.initFolder()).not.toBeUndefined(); 50 }); 51 it('SpClockChart02', function () { 52 expect(arkTsChart.initTimelineChart()).not.toBeUndefined(); 53 }); 54 it('SpClockChart03', function () { 55 expect(arkTsChart.initSnapshotChart()).not.toBeUndefined(); 56 }); 57}); 58