• 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 */
15import { SpStatisticsHttpUtil } from '../../src/statistics/util/SpStatisticsHttpUtil';
16
17SpStatisticsHttpUtil.initStatisticsServerConfig = jest.fn(() => true);
18SpStatisticsHttpUtil.addUserVisitAction = jest.fn(() => true);
19
20const intersectionObserverMock = () => ({
21    observe: () => null,
22});
23window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock);
24import { SpApplication } from '../../src/trace/SpApplication';
25import { LongTraceDBUtils } from '../../src/trace/database/LongTraceDBUtils';
26// @ts-ignore
27window.ResizeObserver = window.ResizeObserver ||
28    jest.fn().mockImplementation(() => ({
29        disconnect: jest.fn(),
30        observe: jest.fn(),
31        unobserve: jest.fn(),
32    }));
33
34describe('spApplication Test', () => {
35    LongTraceDBUtils.getInstance().indexedDBHelp = jest.fn(()=>{})
36    LongTraceDBUtils.getInstance().indexedDBHelp.open = jest.fn(()=>{})
37    LongTraceDBUtils.getInstance().createDBAndTable = jest.fn(()=>{
38        return {
39            then: Function
40        }
41    })
42    document.body.innerHTML = '<sp-application id="sss"></sp-application>';
43    let spApplication = document.querySelector('#sss') as SpApplication;
44    it('spApplicationTest01', function () {
45        spApplication.dark = true;
46        expect(SpApplication.name).toEqual('SpApplication');
47    });
48
49    it('spApplicationTest02', function () {
50        spApplication.dark = false;
51        expect(spApplication.dark).toBeFalsy();
52    });
53
54    it('spApplicationTest03', function () {
55        spApplication.vs = true;
56        expect(spApplication.vs).toBeTruthy();
57    });
58
59    it('spApplicationTest04', function () {
60        spApplication.vs = false;
61        expect(spApplication.vs).toBeTruthy();
62    });
63
64    it('spApplicationTest05', function () {
65        spApplication.server = true;
66        expect(spApplication.server).toBeTruthy();
67    });
68
69    it('spApplicationTest06', function () {
70        spApplication.server = false;
71        expect(spApplication.server).toBeFalsy();
72    });
73
74    it('spApplicationTest07', function () {
75        spApplication.querySql = true;
76        expect(spApplication.querySql).toBeTruthy();
77    });
78
79    it('spApplicationTest08', function () {
80        spApplication.querySql = false;
81        expect(spApplication.querySql).toBeFalsy();
82    });
83
84    it('spApplicationTest09', function () {
85        spApplication.search = true;
86        expect(spApplication.search).toBeTruthy();
87    });
88
89    it('spApplicationTest10', function () {
90        spApplication.search = false;
91        expect(spApplication.search).toBeFalsy();
92    });
93
94    it('spApplicationTest11', function () {
95        expect(spApplication.removeSkinListener([])).toBeUndefined();
96    });
97
98    it('spApplicationTest15', function () {
99        expect(spApplication.freshMenuDisable()).toBeUndefined();
100    });
101
102    it('spApplicationTest16', function () {
103        expect(spApplication.addSkinListener()).toBeUndefined();
104    });
105
106    it('spApplicationTest17', function () {
107        expect(spApplication.removeSkinListener()).toBeUndefined();
108    });
109
110    it('spApplicationTest18', function () {
111        spApplication.dispatchEvent(new Event('dragleave'));
112    });
113
114    it('spApplicationTest19', function () {
115        spApplication.dispatchEvent(new Event('drop'));
116        spApplication.removeSkinListener = jest.fn(() => undefined);
117        expect(spApplication.removeSkinListener({})).toBeUndefined();
118    });
119    it('spApplicationTest21', function () {
120        expect(spApplication.vsDownload()).toBeUndefined();
121    });
122
123    it('spApplicationTest22', function () {
124        spApplication.showConten = false;
125        expect(spApplication.showContent).toBeFalsy();
126    });
127
128    it('spApplicationTest26', function () {
129        spApplication.dark = false;
130        spApplication.skinChangeArray = ['value'];
131        expect(spApplication.dark).toBeFalsy();
132    });
133
134    it('spApplicationTest29', function () {
135        spApplication.querySql = false;
136        expect(spApplication.querySql).toBeFalsy();
137    });
138});
139