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 { SpInfoAndStats } from '../../../src/trace/component/SpInfoAndStas';
17const sqlit = require('../../../src/trace/database/sql/SqlLite.sql');
18jest.mock('../../../src/trace/database/sql/SqlLite.sql');
19window.ResizeObserver =
20  window.ResizeObserver ||
21  jest.fn().mockImplementation(() => ({
22    disconnect: jest.fn(),
23    observe: jest.fn(),
24    unobserve: jest.fn(),
25  }));
26
27describe('SpInfoAndStasTest', () => {
28  document.body.innerHTML = `<sp-info-and-stats id="ddd"></sp-info-and-stats>`;
29  let spInfoAndStats = document.querySelector('#ddd') as SpInfoAndStats;
30  it('SpInfoAndStasTest01', function () {
31    let spInfoAndStats = new SpInfoAndStats();
32    expect(spInfoAndStats.initElements()).toBeUndefined();
33  });
34
35  it('SpInfoAndStasTest04', function () {
36    let spInfoAndStats = new SpInfoAndStats();
37    expect(
38      spInfoAndStats.initDataTableStyle({
39        children: [
40          {
41            length: 1,
42            style: {
43              backgroundColor: 'var(--dark-background5,#F6F6F6)',
44            },
45          },
46        ],
47      })
48    ).toBeUndefined();
49  });
50
51  it('SpInfoAndStasTest06 ', function () {
52    expect(spInfoAndStats.connectedCallback()).toBeUndefined();
53  });
54
55  it('SpInfoAndStasTest07 ', function () {
56    expect(spInfoAndStats.disconnectedCallback()).toBeUndefined();
57  });
58
59  it('SpInfoAndStasTest08 ', function () {
60    expect(spInfoAndStats.attributeChangedCallback([], [], [])).toBeUndefined();
61  });
62
63  it('SpInfoAndStasTest10', function () {
64    let traceMetaData = sqlit.queryTraceMetaData;
65    let data = [
66      {
67        name: 'a',
68        valueText: '',
69      },
70    ];
71    traceMetaData.mockResolvedValue(data);
72    let selectTraceMetaData = sqlit.querySelectTraceStats;
73    let selectData = [
74      {
75        event_name: '',
76        stat_type: '',
77        count: 1,
78        source: 10,
79        serverity: 23,
80      },
81    ];
82    selectTraceMetaData.mockResolvedValue(selectData);
83    let spInfoAndStats = new SpInfoAndStats();
84    expect(spInfoAndStats.initMetricItemData()).toBeTruthy();
85  });
86  it('SpInfoAndStasTest11', function () {
87    expect(spInfoAndStats.initInfoAndStatsData()).toBeUndefined();
88  });
89});
90