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 '../../../../src/trace/component/chart/SpHiPerf';
17import { SpHiPerf } from '../../../../src/trace/component/chart/SpHiPerf';
18import '../../../../src/trace/component/chart/PerfDataQuery';
19import { PerfDataQuery } from '../../../../src/trace/component/chart/PerfDataQuery';
20const perfSql = require('../../../../src/trace/database/sql/Perf.sql');
21jest.mock('../../../../src/trace/database/sql/Perf.sql');
22jest.mock('../../../../src/trace/component/SpSystemTrace', () => {
23  return {};
24});
25jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => {
26  return {};
27});
28jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => {
29  return {};
30});
31jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {});
32jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => {
33  return {}
34});
35
36describe('perfDataQuery Test', () => {
37  SpHiPerf.stringResult = {
38    existA: true,
39    existF: false,
40    fValue: 1,
41  };
42  let perfFiles  = perfSql.queryPerfFiles;
43  perfFiles.mockResolvedValue([]);
44  let perfDataQuery = new PerfDataQuery();
45  it('perfDataQueryTest01 ', function () {
46    perfDataQuery.initPerfCache();
47    perfDataQuery.initPerfCallChainMap();
48    perfDataQuery.getLibName('id', 0);
49    perfDataQuery.getLibName('id', -1);
50    expect(perfDataQuery.initPerfFiles).not.toBeUndefined();
51  });
52});
53