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 16import { SpBpftraceChart } from '../../../../src/trace/component/chart/SpBpftraceChart'; 17import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; 18import { SampleStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerBpftrace'; 19jest.mock('../../../../src/trace/component/SpSystemTrace', () => { 20 return {}; 21}); 22 23const sqlite = require('../../../../src/trace/database/sql/SqlLite.sql'); 24jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); 25jest.mock('../../../../src/js-heap/model/DatabaseStruct'); 26jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { 27 return {}; 28}); 29jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 30 return {}; 31}); 32const intersectionObserverMock = () => ({ 33 observe: () => null, 34}); 35window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); 36window.ResizeObserver = 37 window.ResizeObserver || 38 jest.fn().mockImplementation(() => ({ 39 disconnect: jest.fn(), 40 observe: jest.fn(), 41 unobserve: jest.fn(), 42 })); 43 44describe('SpBpftraceChart Test', () => { 45 let htmlElement: any = document.createElement('sp-system-trace'); 46 let BpftraceChart = new SpBpftraceChart(htmlElement); 47 let queryStartTime = sqlite.queryStartTime; 48 let queryStartTimeData = [ 49 { 50 start_ts: 10000000, 51 }, 52 ]; 53 queryStartTime.mockResolvedValue(queryStartTimeData); 54 let traceRow = new TraceRow<SampleStruct>(); 55 it('SpBpftraceChart01', function () { 56 expect(BpftraceChart.addTraceRowEventListener(traceRow, 10)).toBeUndefined(); 57 }); 58 it('SpBpftraceChart02', function () { 59 expect(BpftraceChart.resetChartData(traceRow)).toBeUndefined(); 60 }); 61}); 62