• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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';
17jest.mock('../../../../src/trace/component/SpSystemTrace', () => {
18  return {};
19});
20
21const sqlite = require('../../../../src/trace/database/sql/SqlLite.sql');
22jest.mock('../../../../src/trace/database/sql/SqlLite.sql');
23jest.mock('../../../../src/js-heap/model/DatabaseStruct');
24jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => {
25  return {};
26});
27jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => {
28  return {};
29});
30const intersectionObserverMock = () => ({
31  observe: () => null,
32});
33window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock);
34window.ResizeObserver =
35  window.ResizeObserver ||
36  jest.fn().mockImplementation(() => ({
37    disconnect: jest.fn(),
38    observe: jest.fn(),
39    unobserve: jest.fn(),
40  }));
41describe('SpArkTsChart Test', () => {
42  let htmlElement: any = document.createElement('sp-system-trace');
43  let spSampleChart = new SpBpftraceChart(htmlElement);
44  let startTime = sqlite.queryStartTime;
45  let startTimeData = [
46    {startTs: 102132121}
47  ];
48  startTime.mockResolvedValue(startTimeData);
49  it('SpSampleChartTest01', function () {
50    expect(spSampleChart.init).toBeTruthy();
51  });
52  it('SpSampleChartTest02 ', function () {
53    expect(spSampleChart.initSample(startTimeData[0].startTs, false)).toBeTruthy();
54  });
55});
56