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