• 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 { LitModal } from '../../../dist/base-ui/modal/LitModal.js';
18
19window.ResizeObserver =
20  window.ResizeObserver ||
21  jest.fn().mockImplementation(() => ({
22    disconnect: jest.fn(),
23    observe: jest.fn(),
24    unobserve: jest.fn(),
25  }));
26
27describe('LitModal Test', () => {
28  it('LitModalTest01', function () {
29    let litModal = new LitModal();
30    expect(litModal).not.toBeUndefined();
31  });
32
33  it('LitModalTest02', function () {
34    let litModal = new LitModal();
35    litModal.resizeable = true;
36    expect(litModal).not.toBeUndefined();
37  });
38
39  it('LitModalTest03', function () {
40    let litModal = new LitModal();
41    litModal.resizeable = false;
42    expect(litModal).not.toBeUndefined();
43  });
44
45  it('LitModalTest04', function () {
46    let litModal = new LitModal();
47    litModal.moveable = false;
48    expect(litModal).not.toBeUndefined();
49  });
50
51  it('LitModalTest05', function () {
52    let litModal = new LitModal();
53    litModal.moveable = true;
54    expect(litModal).not.toBeUndefined();
55  });
56
57  it('LitModalTest06', function () {
58    document.body.innerHTML = `
59        <div>
60            <lit-modal resizeable="true" style='width:100px height:100px ' id='lit-modal'></lit-modal>
61        </div> `;
62    let litmode = document.getElementById('lit-modal') as LitModal;
63    let mouseOutEvent: MouseEvent = new MouseEvent('mousemove', <MouseEventInit>{ movementX: 1, movementY: 2 });
64    litmode.dispatchEvent(mouseOutEvent);
65  });
66
67  it('LitModalTest06', function () {
68    document.body.innerHTML = `
69        <div>
70            <lit-modal moveable="true" style='width:100px height:100px ' id='lit-modal'></lit-modal>
71        </div> `;
72    let litmode = document.getElementById('lit-modal') as LitModal;
73
74    let mouseOutEvent: MouseEvent = new MouseEvent('mousedown', <MouseEventInit>{ movementX: 1, movementY: 2 });
75    litmode.dispatchEvent(mouseOutEvent);
76  });
77
78  it('LitModalTest07', function () {
79    document.body.innerHTML = `
80        <div>
81            <lit-modal moveable="true" style='width:100px height:100px ' id='lit-modal'></lit-modal>
82        </div> `;
83    let litmode = document.getElementById('lit-modal') as LitModal;
84
85    let mouseOutEvent: MouseEvent = new MouseEvent('mouseleave', <MouseEventInit>{ movementX: 1, movementY: 2 });
86    litmode.dispatchEvent(mouseOutEvent);
87  });
88
89  it('LitModalTest08', function () {
90    document.body.innerHTML = `
91        <div>
92            <lit-modal moveable="true" style='width:100px height:100px ' id='lit-modal'></lit-modal>
93        </div> `;
94    let litmode = document.getElementById('lit-modal') as LitModal;
95    let mouseOutEvent: MouseEvent = new MouseEvent('mousemove', <MouseEventInit>{ clientX: 1, clientY: 2 });
96    litmode.dispatchEvent(mouseOutEvent);
97  });
98  it('LitModalTest08', function () {
99    let litModal = new LitModal();
100    litModal.okText = 'ok-text';
101    expect(litModal).not.toBeUndefined();
102  });
103  it('LitModalTest09', function () {
104    let litModal = new LitModal();
105    litModal.cancelText = 'cancel-text';
106    expect(litModal).not.toBeUndefined();
107  });
108  it('LitModalTest10', function () {
109    let litModal = new LitModal();
110    litModal.title = 'title';
111    expect(litModal).not.toBeUndefined();
112  });
113  it('LitModalTest11', function () {
114    let litModal = new LitModal();
115    litModal.visible = false;
116    expect(litModal).not.toBeUndefined();
117  });
118  it('LitModalTest12', function () {
119    let litModal = new LitModal();
120    litModal.visible = true;
121    expect(litModal).not.toBeUndefined();
122  });
123  it('LitModalTest13', function () {
124    let litModal = new LitModal();
125    litModal.width = 'width';
126    expect(litModal).not.toBeUndefined();
127  });
128  it('LitModalTest14', function () {
129    let litModal = new LitModal();
130    expect(litModal.adoptedCallback()).toBeUndefined();
131  });
132});
133