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/SpSystemTrace', () => {
17  return {};
18});
19
20const sqlite = require('../../../../src/trace/database/sql/Irq.sql');
21jest.mock('../../../../src/trace/database/sql/Irq.sql');
22jest.mock('../../../../src/js-heap/model/DatabaseStruct');
23
24window.ResizeObserver =
25  window.ResizeObserver ||
26  jest.fn().mockImplementation(() => ({
27    disconnect: jest.fn(),
28    observe: jest.fn(),
29    unobserve: jest.fn(),
30  }));
31const intersectionObserverMock = () => ({
32  observe: () => null,
33});
34window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock);
35
36import { SpIrqChart } from '../../../../src/trace/component/chart/SpIrqChart';
37
38describe('SpIrqChart Test', () => {
39  let trace: any = document.createElement('sp-system-trace');
40  let irqChart = new SpIrqChart(trace);
41  let irqList = sqlite.queryIrqList;
42  let irqListData = [
43    {
44      name: 'test',
45      cpu: 0,
46    },
47  ];
48  irqList.mockResolvedValue(irqListData);
49  let allIrqNames = sqlite.queryAllIrqNames;
50  let irqNameData = [
51    {
52      name: 'test',
53      cpu: 0,
54    },
55  ];
56  allIrqNames.mockResolvedValue(irqNameData);
57
58  it('SpIrqChart01', function () {
59    expect(irqChart.init()).toBeDefined();
60  });
61
62  it('SpIrqChart02', function () {
63    expect(irqChart.initFolder()).toBeDefined();
64  });
65});
66