• 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 {LitMainMenu} from "../../../dist/base-ui/menu/LitMainMenu.js";
18import {MenuItem} from "../../../src/base-ui/menu/LitMainMenu.js";
19
20describe("LitMainMenu Test", () => {
21
22    it('LitMainMenu01', () => {
23        let litMainMenu = new LitMainMenu();
24        expect(litMainMenu).not.toBeUndefined()
25        expect(litMainMenu).not.toBeNull()
26    });
27
28    it('LitMainMenu01', () => {
29        let litMainMenu = new LitMainMenu();
30        expect(litMainMenu).not.toBeUndefined()
31        expect(litMainMenu).not.toBeNull()
32    });
33
34    it('LitMainMenu02', () => {
35        let litMainMenu = new LitMainMenu();
36        litMainMenu.menus = [
37            {
38                collapsed: false,
39                title: 'Navigation',
40                describe: 'Open or record a new trace',
41                children: [
42                    {
43                        title: "Open trace file",
44                        icon: "folder",
45                        fileChoose: true,
46                        fileHandler: function (ev: InputEvent) {
47                        }
48
49                    },
50                    {
51                        title: "Record new trace", icon: "copyhovered", clickHandler: function (item: MenuItem) {
52                        }
53                    }
54                ]
55            }
56        ]
57        expect(litMainMenu.menus.length).toBe(1)
58    });
59
60    it('LitMainMenu03', () => {
61        let litMainMenu = new LitMainMenu();
62        expect(litMainMenu.initHtml()).toMatchInlineSnapshot(`
63"
64        <style>
65        :host{
66            display: flex;
67            flex-direction: column;
68            width: 248px;
69            background-color: var(--dark-background,#FFFFFF);
70            height: 100vh;
71        }
72        .menu-body ::-webkit-scrollbar-track
73        {
74            border-radius:10px;
75            background-color:#F5F5F5;
76        }
77        .menu-body ::-webkit-scrollbar-thumb
78        {
79            border-radius:10px;
80            background-color: var(--dark-background,#FFFFFF);
81
82        }
83        .header{
84            display: grid;
85            background-color: var(--dark-background1,#FFFFFF);
86            border-bottom: 1px solid var(--dark-background1,#EFEFEF);
87            color: #47A7E0;
88            font-size: 1.4rem;
89            padding-left: 20px;
90            /*padding-right: 10px;*/
91            gap: 0 20px;
92            box-sizing: border-box;
93            width: 100%;
94            height: 56px;
95            grid-template-columns: min-content 1fr min-content;
96            grid-template-rows: auto;
97        }
98        .header *{
99            align-self: center;
100            user-select: none;
101        }
102        .version{
103            color: #94979d;
104            padding: 20px;
105            font-size: 0.6rem;
106            width: 100%;
107            text-align: right;
108        }
109        *{
110            box-sizing: border-box;
111        }
112        .menu-button{
113            height: 47px;
114            width: 48px;
115            display: flex;
116            align-content: center;
117            justify-content: right;
118            cursor: pointer;
119        }
120        </style>
121        <div name=\\"header\\" class=\\"header\\">
122            <img src=\\"img/logo.png\\"/>
123                <div class=\\"menu-button\\">
124                    <lit-icon name=\\"menu\\" size=\\"20\\" color=\\"var(--dark-color1,#4D4D4D)\\"></lit-icon>
125                </div>
126            </div>
127            <div class=\\"menu-body\\" style=\\"overflow: auto;overflow-x:hidden;height: 100%\\">
128                <slot id=\\"st\\" ></slot>
129            </div>
130        <div class=\\"version\\" style=\\"\\">
131        </div>
132        "
133`);
134    });
135
136    it('LitMainMenu04', () => {
137        let litMainMenu = new LitMainMenu();
138        litMainMenu.menus = [
139            {
140                collapsed: true,
141                title: 'Navigation',
142                describe: 'Open or record a new trace',
143                children: [
144                    {
145                        title: "Open trace file",
146                        icon: "folder",
147                        fileChoose: true,
148                        fileHandler: function (ev: InputEvent) {
149                        }
150
151                    },
152                    {
153                        title: "Record new trace", icon: "copyhovered", clickHandler: function (item: MenuItem) {
154                        }
155                    }
156                ]
157            }
158        ]
159        expect(litMainMenu.menus.length).toBe(1)
160    });
161})
162