/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-ignore
import {LitTable} from "../../../dist/base-ui/table/lit-table.js";
import {LitTableColumn} from "../../../src/base-ui/table/lit-table-column.js";
describe('LitTable Test', () => {
window.ResizeObserver = window.ResizeObserver ||
jest.fn().mockImplementation(() => ({
disconnect: jest.fn(),
observe: jest.fn(),
unobserve: jest.fn(),
}));
let litTable = new LitTable();
litTable.selectable = true
litTable.selectable = false
litTable.scrollY = 'scrollY'
litTable.dataSource = []
litTable.dataSource = [{
id: 1,
name: 'name'
}, {
id: 2,
name: 'nameValue'
}]
const td = {
style: {
position: 'sticky',
left: '0px',
right: '0px',
boxShadow: '3px 0px 5px #33333333'
}
}
const placement = "left"
const element = {
style: {
display: 'none',
transform: 'translateY'
},
childNodes:{forEach:true},
onclick: 1
}
const rowObject = {
children: {
length: 1,
},
data: [{isSelected:undefined}],
depth: 1,
top: 1
}
const firstElement = {
style: {
display: 'none',
paddingLeft: "",
transform: 'translateY'
},
innerHTML: "",
title: "",
firstChild: null,
onclick: 1
}||undefined
JSON.parse = jest.fn(() => [['children', 'father'], ['children', 'father']])
litTable.columns = litTable.columns || jest.fn(() => true)
litTable.ds = jest.fn(() => [{
id: 1,
name: 'name'
}, {
id: 2,
name: 'nameValue'
}])
litTable.tbodyElement = jest.fn(() => ({
innerHTML: ''
}))
litTable.tableColumns = jest.fn(() => [])
litTable.tableColumns.forEach = jest.fn(() => [])
it('LitTableTest01', () => {
expect(litTable.adoptedCallback()).toBeUndefined();
})
it('LitTableTest02', () => {
litTable.ds.forEach = jest.fn(() => true)
expect(litTable.renderTable()).toBeUndefined();
})
it('LitTableTest04', () => {
litTable.switch = document.querySelector("#switch") as HTMLInputElement;
expect(litTable.connectedCallback()).toBeUndefined()
})
it('LitTableTest05', () => {
let rowLength = litTable.getCheckRows().length == 0;
expect(rowLength).toBeTruthy()
})
it('LitTableTest06', () => {
expect(litTable.deleteRowsCondition(() => {
return true
})).toBeUndefined()
})
it('LitTableTest07', () => {
expect(litTable.selectable).not.toBeUndefined()
})
it('LitTableTest08', () => {
litTable.selectable = true
expect(litTable.selectable).toBeTruthy()
})
it('LitTableTest09', () => {
expect(litTable.scrollY).not.toBeUndefined()
})
it('LitTableTest10', () => {
expect(litTable.dataSource).not.toBeUndefined()
})
it('LitTableTest11', () => {
expect(litTable.recycleDataSource).not.toBeUndefined()
})
it('LitTableTest12', () => {
expect(litTable.fixed(td, placement)).toBeUndefined()
})
it('LitTableTest13', () => {
expect(litTable.fixed(td, "right")).toBe(undefined)
})
it('LitTableTest14', () => {
expect(litTable.meauseElementHeight()).toBe(27)
})
it('LitTableTest15', () => {
expect(litTable.meauseTreeElementHeight()).toBe(27)
})
it('LitTableTest16', () => {
document.body.innerHTML = "