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 { DrawerCpuTabs } from '../../../../src/trace/component/schedulingAnalysis/DrawerCpuTabs'; 16import crypto from 'crypto'; 17// @ts-ignore 18window.ResizeObserver = 19 window.ResizeObserver || 20 jest.fn().mockImplementation(() => ({ 21 disconnect: jest.fn(), 22 observe: jest.fn(), 23 unobserve: jest.fn(), 24 })); 25 26Object.defineProperty(global.self, 'crypto', { 27 value: { 28 getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), 29 }, 30}); 31 32describe('DrawerCpuTabs Test', () => { 33 it('DrawerCpuTabsTest01', () => { 34 let drawerCpuTabs = new DrawerCpuTabs(); 35 expect(drawerCpuTabs.init(1, '1')).not.toBe(0); 36 }); 37 it('DrawerCpuTabsTest02', () => { 38 let drawerCpuTabs = new DrawerCpuTabs(); 39 drawerCpuTabs.init(1, '2'); 40 expect(drawerCpuTabs.cpuNumber).toEqual(1); 41 }); 42 it('DrawerCpuTabsTest03', () => { 43 let drawerCpuTabs = new DrawerCpuTabs(); 44 drawerCpuTabs.init(1, '3'); 45 expect(drawerCpuTabs.cpuNumber).toEqual(1); 46 }); 47 it('DrawerCpuTabsTest04', () => { 48 let drawerCpuTabs = new DrawerCpuTabs(); 49 expect(drawerCpuTabs.clearData()).toBeUndefined(); 50 }); 51}); 52