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 16const intersectionObserverMock = () => ({ 17 observe: () => null, 18}); 19window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); 20jest.mock('../../../../src/js-heap/model/DatabaseStruct'); 21import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; 22jest.mock('../../../../src/trace/component/SpSystemTrace', () => { 23 return {}; 24}); 25 26const sqlite = require('../../../../src/trace/database/sql/ProcessThread.sql'); 27jest.mock('../../../../src/trace/database/sql/ProcessThread.sql'); 28 29// @ts-ignore 30window.ResizeObserver = window.ResizeObserver || 31 jest.fn().mockImplementation(() => ({ 32 disconnect: jest.fn(), 33 observe: jest.fn(), 34 unobserve: jest.fn(), 35 })); 36describe('SpChartManager Test', () => { 37 let htmlElement: any = document.createElement('sp-system-trace'); 38 let chartManager = new SpChartManager(htmlElement); 39 let queryDataDICT = sqlite.queryDataDICT; 40 let dataDICT = [ 41 { 42 id: 251, 43 data: 'delay', 44 }, 45 { 46 id: 251, 47 data: 'caller', 48 }, 49 ]; 50 queryDataDICT.mockResolvedValue(dataDICT); 51 52 it('SpChartManager01', function () { 53 expect(chartManager).not.toBeUndefined(); 54 }); 55}); 56