• 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 */
15
16// @ts-ignore
17import {StackBar} from "../../../dist/trace/component/StackBar.js"
18
19describe('StackBar Test', () => {
20
21    let stackBar = new StackBar();
22
23    it('StackBarTest01', function () {
24        expect(stackBar.initHtml()).not.toBe('')
25    });
26
27    it('StackBarTest02', function () {
28        expect(stackBar.initElements()).toBeUndefined()
29    });
30
31    it('StackBarTest03', function () {
32        let stateWidth = stackBar.getStateWidth('state');
33        let hasWidth = stateWidth > 0;
34        expect(hasWidth).toBeTruthy();
35    });
36
37    it('StackBarTest04', function () {
38        let htmlDivElement = stackBar.createBarElement({
39            state: "",
40            color: "",
41            value: 0,
42        }, 5);
43        let hasDivEl = htmlDivElement.toLocaleString().length > 5;
44        expect(hasDivEl).toBeTruthy();
45    });
46
47    it('StackBarTest05', function () {
48        expect(stackBar.initHtml()).toMatchInlineSnapshot(`
49"
50        <style>
51            :host([mode='hidden']){
52                display: none;
53            }
54            :host{
55                display: block;
56                /*background-color: rebeccapurple;*/
57            }
58            .state-text{
59                width: 10%;display: inline-block;overflow: hidden;white-space: nowrap;padding: 5px; margin-right: 2px;font-size: 9pt;
60            }
61            </style>
62            <div style=\\"display: flex;flex-direction: row;width: 100%;\\" id=\\"container\\">
63            </div>
64        "
65`);
66   });
67})
68