• 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 { LitSlicer, LitSlicerTrack } from '../../../dist/base-ui/slicer/lit-slicer.js';
18
19describe('slicer Test', () => {
20  it('slicerTest01', function () {
21    let litSlicer = new LitSlicer();
22    expect(litSlicer).not.toBeUndefined();
23    expect(litSlicer).not.toBeNull();
24  });
25  it('slicerTest02', function () {
26    let litSlicerTrack = new LitSlicerTrack();
27    expect(litSlicerTrack).not.toBeUndefined();
28    expect(litSlicerTrack).not.toBeNull();
29  });
30  it('slicerTest03', function () {
31    let litSlicerTrack = new LitSlicerTrack();
32    expect(litSlicerTrack.rangeLeft).toBe(200);
33  });
34  it('slicerTest04', function () {
35    let litSlicerTrack = new LitSlicerTrack();
36    litSlicerTrack.rangeLeft = true;
37    expect(litSlicerTrack.rangeLeft).not.toBeTruthy();
38  });
39  it('slicerTest05', function () {
40    let litSlicerTrack = new LitSlicerTrack();
41    expect(litSlicerTrack.rangeRight).toBe(300);
42  });
43  it('slicerTest09', function () {
44    let litSlicerTrack = new LitSlicerTrack();
45    litSlicerTrack.rangeRight = false;
46    expect(litSlicerTrack.rangeRight).toBeFalsy();
47  });
48  it('slicerTest06', function () {
49    let litSlicer = new LitSlicer();
50    expect(litSlicer.attributeChangedCallback()).toBeUndefined();
51  });
52  it('slicerTest07', function () {
53    let litSlicerTrack = new LitSlicerTrack();
54    expect(litSlicerTrack.adoptedCallback()).toBeUndefined();
55  });
56  it('slicerTest08', function () {
57    let litSlicerTrack = new LitSlicerTrack();
58    expect(litSlicerTrack.attributeChangedCallback()).toBeUndefined();
59  });
60  it('slicerTest10', function () {
61    let litSlicer = new LitSlicer();
62    litSlicer.direction = 'h';
63    expect(litSlicer.connectedCallback()).toBeUndefined();
64  });
65  it('slicerTest11', function () {
66    let litSlicer = new LitSlicer();
67    litSlicer.direction = 'v';
68    expect(litSlicer.direction).toBeUndefined();
69  });
70  it('slicerTest12', function () {
71    let litSlicer = new LitSlicer();
72    litSlicer.style = 'v';
73    expect(litSlicer.style).toBeUndefined();
74  });
75
76  it('slicerTest13', function () {
77    let litSlicer = new LitSlicer();
78    litSlicer.style = 'v';
79    document.body.innerHTML = `
80        <lit-slicer-track id="slicer_2"></lit-slicer-track>
81        <lit-slicer-track id="slicer"></lit-slicer-track>
82        `;
83    let slice = document.getElementById('slicer') as LitSlicerTrack;
84    let line = slice.shadowRoot?.querySelector('#root') as HTMLDivElement;
85    let mouseOutEvent: MouseEvent = new MouseEvent('mousedown', <MouseEventInit>{ movementX: 1, movementY: 2 });
86
87    line.dispatchEvent(mouseOutEvent);
88    let onmousemove: MouseEvent = new MouseEvent('mousemove', <MouseEventInit>{ movementX: 1, movementY: 2 });
89    document.dispatchEvent(onmousemove);
90    let onmouseleave: MouseEvent = new MouseEvent('mouseleave', <MouseEventInit>{ movementX: 1, movementY: 2 });
91    document.dispatchEvent(onmouseleave);
92    let onmouseup: MouseEvent = new MouseEvent('mouseup', <MouseEventInit>{
93      movementX: 1,
94      movementY: 2,
95    });
96    document.dispatchEvent(onmouseup);
97    expect(litSlicer.style).toBeUndefined();
98  });
99});
100