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