• 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 { LitAllocationSelect } from '../../../dist/base-ui/select/LitAllocationSelect.js';
18
19describe('LitAllocationSelect Test', () => {
20  let litAllocationSelect = new LitAllocationSelect();
21  it('LitAllocationSelectTest01', function () {
22    expect(litAllocationSelect.value).toBe('');
23  });
24  it('LitAllocationSelectTest02', () => {
25    expect(litAllocationSelect.processData).toBeUndefined();
26  });
27  it('LitAllocationSelectTest03', function () {
28    expect(litAllocationSelect.placement).toBe('');
29  });
30  it('LitAllocationSelectTest04', function () {
31    litAllocationSelect.placement = true;
32    expect(litAllocationSelect.placement).toBeTruthy();
33  });
34  it('LitAllocationSelectTest05', function () {
35    litAllocationSelect.placement = false;
36    expect(litAllocationSelect.placement).toBeFalsy();
37  });
38  it('LitAllocationSelectTest06', function () {
39    expect(litAllocationSelect.listHeight).toBe('256px');
40  });
41  it('LitAllocationSelectTest07', function () {
42    litAllocationSelect.listHeight = 'test';
43    expect(litAllocationSelect.listHeight).toBe('test');
44  });
45  it('LitAllocationSelectTest08', function () {
46    litAllocationSelect.placeholder = 'test';
47    expect(litAllocationSelect.placeholder).toBe('test');
48  });
49  it('LitAllocationSelectTest09', () => {
50    expect(litAllocationSelect.initElements()).toBeUndefined();
51  });
52
53  it('LitAllocationSelectTest10', () => {
54    litAllocationSelect.processData = [];
55    expect(litAllocationSelect.processData).toBe(undefined);
56  });
57
58  it('LitAllocationSelectTest12', () => {
59    litAllocationSelect.processData = ['1', '2', '3'];
60    expect(litAllocationSelect.processData).toBe(undefined);
61  });
62
63  it('LitAllocationSelectTest11', () => {
64    const onclick = jest.fn();
65    let allocationSelect = (document.body.innerHTML = `
66            <lit-allocation-select id='select'></lit-allocation-select>
67        `);
68    const select = document.getElementById('select');
69    expect(onclick).not.toBeCalled();
70    select!.onclick = onclick;
71    select!.click();
72    expect(onclick).toBeCalled();
73    expect(onclick).toHaveBeenCalledTimes(1);
74  });
75});
76