/* * Copyright (C) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { CpuUsage, Freq } from '../../../src/trace/bean/CpuUsage'; describe('CpuUsage Test', () => { let cpuUsage = new CpuUsage(); let freq = new Freq(); it('CpuUsageTest01', function () { cpuUsage = { cpu: 0, usage: 0, usageStr: '', top1: 0, top2: 0, top3: 0, top1Percent: 0, top1PercentStr: '', top2Percent: 0, top2PercentStr: '', top3Percent: 0, top3PercentStr: '', }; expect(cpuUsage).not.toBeUndefined(); expect(cpuUsage).toMatchInlineSnapshot( { cpu: expect.any(Number), usage: expect.any(Number), usageStr: expect.any(String), top1: expect.any(Number), top2: expect.any(Number), top3: expect.any(Number), top1Percent: expect.any(Number), top1PercentStr: expect.any(String), top2Percent: expect.any(Number), top2PercentStr: expect.any(String), top3Percent: expect.any(Number), top3PercentStr: expect.any(String) }, ` { "cpu": Any, "top1": Any, "top1Percent": Any, "top1PercentStr": Any, "top2": Any, "top2Percent": Any, "top2PercentStr": Any, "top3": Any, "top3Percent": Any, "top3PercentStr": Any, "usage": Any, "usageStr": Any, } `); }); it('CpuUsageTest02', function () { cpuUsage = { cpu: 0, value: 0, startNs: 0, dur: 0, }; expect(freq).not.toBeUndefined(); expect(cpuUsage).toMatchInlineSnapshot( { cpu: expect.any(Number), value: expect.any(Number), startNs: expect.any(Number), dur: expect.any(Number) }, ` { "cpu": Any, "dur": Any, "startNs": Any, "value": Any, } `); }); });