1fb726d48Sopenharmony_ci/* 2fb726d48Sopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd. 3fb726d48Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4fb726d48Sopenharmony_ci * you may not use this file except in compliance with the License. 5fb726d48Sopenharmony_ci * You may obtain a copy of the License at 6fb726d48Sopenharmony_ci * 7fb726d48Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8fb726d48Sopenharmony_ci * 9fb726d48Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10fb726d48Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11fb726d48Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12fb726d48Sopenharmony_ci * See the License for the specific language governing permissions and 13fb726d48Sopenharmony_ci * limitations under the License. 14fb726d48Sopenharmony_ci */ 15fb726d48Sopenharmony_ci 16fb726d48Sopenharmony_ciimport { LitTable } from '../../../src/base-ui/table/lit-table'; 17fb726d48Sopenharmony_ciimport { LitTableColumn } from '../../../src/base-ui/table/lit-table-column'; 18fb726d48Sopenharmony_ciimport { TableRowObject } from '../../../src/base-ui/table/TableRowObject'; 19fb726d48Sopenharmony_ciimport { LitProgressBar } from '../../../src/base-ui/progress-bar/LitProgressBar'; 20fb726d48Sopenharmony_ciimport { LitIcon } from '../../../src/base-ui/icon/LitIcon'; 21fb726d48Sopenharmony_cidescribe('LitTable Test', () => { 22fb726d48Sopenharmony_ci window.ResizeObserver = 23fb726d48Sopenharmony_ci window.ResizeObserver || 24fb726d48Sopenharmony_ci jest.fn().mockImplementation(() => ({ 25fb726d48Sopenharmony_ci disconnect: jest.fn(), 26fb726d48Sopenharmony_ci observe: jest.fn(), 27fb726d48Sopenharmony_ci unobserve: jest.fn(), 28fb726d48Sopenharmony_ci })); 29fb726d48Sopenharmony_ci let litTable = new LitTable(); 30fb726d48Sopenharmony_ci litTable.selectable = true; 31fb726d48Sopenharmony_ci litTable.selectable = false; 32fb726d48Sopenharmony_ci litTable.scrollY = 'scrollY'; 33fb726d48Sopenharmony_ci 34fb726d48Sopenharmony_ci litTable.dataSource = []; 35fb726d48Sopenharmony_ci 36fb726d48Sopenharmony_ci litTable.dataSource = [ 37fb726d48Sopenharmony_ci { 38fb726d48Sopenharmony_ci id: 1, 39fb726d48Sopenharmony_ci name: 'name', 40fb726d48Sopenharmony_ci }, 41fb726d48Sopenharmony_ci { 42fb726d48Sopenharmony_ci id: 2, 43fb726d48Sopenharmony_ci name: 'nameValue', 44fb726d48Sopenharmony_ci }, 45fb726d48Sopenharmony_ci ]; 46fb726d48Sopenharmony_ci const td = { 47fb726d48Sopenharmony_ci style: { 48fb726d48Sopenharmony_ci position: 'sticky', 49fb726d48Sopenharmony_ci left: '0px', 50fb726d48Sopenharmony_ci right: '0px', 51fb726d48Sopenharmony_ci boxShadow: '3px 0px 5px #33333333', 52fb726d48Sopenharmony_ci }, 53fb726d48Sopenharmony_ci }; 54fb726d48Sopenharmony_ci const placement = 'left'; 55fb726d48Sopenharmony_ci 56fb726d48Sopenharmony_ci const element = { 57fb726d48Sopenharmony_ci style: { 58fb726d48Sopenharmony_ci display: 'none', 59fb726d48Sopenharmony_ci transform: 'translateY', 60fb726d48Sopenharmony_ci }, 61fb726d48Sopenharmony_ci childNodes: { forEach: true }, 62fb726d48Sopenharmony_ci onclick: 1, 63fb726d48Sopenharmony_ci }; 64fb726d48Sopenharmony_ci const rowObject = { 65fb726d48Sopenharmony_ci children: { 66fb726d48Sopenharmony_ci length: 1, 67fb726d48Sopenharmony_ci }, 68fb726d48Sopenharmony_ci data: [{ isSelected: undefined }], 69fb726d48Sopenharmony_ci depth: 1, 70fb726d48Sopenharmony_ci top: 1, 71fb726d48Sopenharmony_ci }; 72fb726d48Sopenharmony_ci const firstElement = 73fb726d48Sopenharmony_ci { 74fb726d48Sopenharmony_ci style: { 75fb726d48Sopenharmony_ci display: 'none', 76fb726d48Sopenharmony_ci paddingLeft: '', 77fb726d48Sopenharmony_ci transform: 'translateY', 78fb726d48Sopenharmony_ci }, 79fb726d48Sopenharmony_ci innerHTML: '', 80fb726d48Sopenharmony_ci title: '', 81fb726d48Sopenharmony_ci firstChild: null, 82fb726d48Sopenharmony_ci onclick: 1, 83fb726d48Sopenharmony_ci } || undefined; 84fb726d48Sopenharmony_ci 85fb726d48Sopenharmony_ci litTable.columns = litTable.columns || jest.fn(() => true); 86fb726d48Sopenharmony_ci 87fb726d48Sopenharmony_ci litTable.tbodyElement = jest.fn(() => ({ 88fb726d48Sopenharmony_ci innerHTML: '', 89fb726d48Sopenharmony_ci })); 90fb726d48Sopenharmony_ci 91fb726d48Sopenharmony_ci litTable.tableColumns = jest.fn(() => []); 92fb726d48Sopenharmony_ci 93fb726d48Sopenharmony_ci litTable.tableColumns.forEach = jest.fn(() => []); 94fb726d48Sopenharmony_ci 95fb726d48Sopenharmony_ci it('LitTableTest01', () => { 96fb726d48Sopenharmony_ci expect(litTable.adoptedCallback()).toBeUndefined(); 97fb726d48Sopenharmony_ci }); 98fb726d48Sopenharmony_ci 99fb726d48Sopenharmony_ci it('LitTableTest02', () => { 100fb726d48Sopenharmony_ci litTable.ds = [ 101fb726d48Sopenharmony_ci { 102fb726d48Sopenharmony_ci name: 'StartTime', 103fb726d48Sopenharmony_ci value: '1s 489ms 371μs ', 104fb726d48Sopenharmony_ci }, 105fb726d48Sopenharmony_ci { 106fb726d48Sopenharmony_ci name: 'Duration', 107fb726d48Sopenharmony_ci value: '6ms 440μs ', 108fb726d48Sopenharmony_ci }, 109fb726d48Sopenharmony_ci { 110fb726d48Sopenharmony_ci name: 'State', 111fb726d48Sopenharmony_ci value: 'Sleeping', 112fb726d48Sopenharmony_ci }, 113fb726d48Sopenharmony_ci { 114fb726d48Sopenharmony_ci name: 'Process', 115fb726d48Sopenharmony_ci value: 'hilogd [441] ', 116fb726d48Sopenharmony_ci }, 117fb726d48Sopenharmony_ci ]; 118fb726d48Sopenharmony_ci litTable.setAttribute('selectable', '123'); 119fb726d48Sopenharmony_ci let tableColmn = document.createElement('lit-table-column') as LitTableColumn; 120fb726d48Sopenharmony_ci tableColmn.setAttribute('title', '621'); 121fb726d48Sopenharmony_ci tableColmn.setAttribute('data-index', '16'); 122fb726d48Sopenharmony_ci tableColmn.setAttribute('key', '261'); 123fb726d48Sopenharmony_ci tableColmn.setAttribute('align', 'flex-start'); 124fb726d48Sopenharmony_ci tableColmn.setAttribute('height', '202px'); 125fb726d48Sopenharmony_ci let tableColmn1 = document.createElement('lit-table-column') as LitTableColumn; 126fb726d48Sopenharmony_ci tableColmn1.setAttribute('title', '12'); 127fb726d48Sopenharmony_ci tableColmn1.setAttribute('data-index', '12'); 128fb726d48Sopenharmony_ci tableColmn1.setAttribute('key', '67'); 129fb726d48Sopenharmony_ci tableColmn1.setAttribute('align', 'flex-start'); 130fb726d48Sopenharmony_ci tableColmn1.setAttribute('height', '120px'); 131fb726d48Sopenharmony_ci let tableColmn2 = document.createElement('lit-table-column') as LitTableColumn; 132fb726d48Sopenharmony_ci tableColmn2.setAttribute('title', '13'); 133fb726d48Sopenharmony_ci tableColmn2.setAttribute('data-index', '13'); 134fb726d48Sopenharmony_ci tableColmn2.setAttribute('key', '163'); 135fb726d48Sopenharmony_ci tableColmn2.setAttribute('align', 'flex-start'); 136fb726d48Sopenharmony_ci tableColmn2.setAttribute('height', '4px'); 137fb726d48Sopenharmony_ci litTable.tableColumns = [tableColmn, tableColmn1, tableColmn2]; 138fb726d48Sopenharmony_ci litTable.tbodyElement = document.createElement('div'); 139fb726d48Sopenharmony_ci expect(litTable.renderTable()).toBeUndefined(); 140fb726d48Sopenharmony_ci }); 141fb726d48Sopenharmony_ci 142fb726d48Sopenharmony_ci it('LitTableTest03', () => { 143fb726d48Sopenharmony_ci litTable.switch = document.querySelector('#switch') as HTMLInputElement; 144fb726d48Sopenharmony_ci expect(litTable.connectedCallback()).toBeUndefined(); 145fb726d48Sopenharmony_ci }); 146fb726d48Sopenharmony_ci 147fb726d48Sopenharmony_ci it('LitTableTest04', () => { 148fb726d48Sopenharmony_ci let rowLength = litTable.getCheckRows().length == 0; 149fb726d48Sopenharmony_ci expect(rowLength).toBeTruthy(); 150fb726d48Sopenharmony_ci }); 151fb726d48Sopenharmony_ci 152fb726d48Sopenharmony_ci it('LitTableTest05', () => { 153fb726d48Sopenharmony_ci expect( 154fb726d48Sopenharmony_ci litTable.deleteRowsCondition(() => { 155fb726d48Sopenharmony_ci return true; 156fb726d48Sopenharmony_ci }) 157fb726d48Sopenharmony_ci ).toBeUndefined(); 158fb726d48Sopenharmony_ci }); 159fb726d48Sopenharmony_ci 160fb726d48Sopenharmony_ci it('LitTableTest06', () => { 161fb726d48Sopenharmony_ci expect(litTable.selectable).not.toBeUndefined(); 162fb726d48Sopenharmony_ci }); 163fb726d48Sopenharmony_ci 164fb726d48Sopenharmony_ci it('LitTableTest07', () => { 165fb726d48Sopenharmony_ci litTable.selectable = true; 166fb726d48Sopenharmony_ci expect(litTable.selectable).toBeTruthy(); 167fb726d48Sopenharmony_ci }); 168fb726d48Sopenharmony_ci 169fb726d48Sopenharmony_ci it('LitTableTest08', () => { 170fb726d48Sopenharmony_ci expect(litTable.scrollY).not.toBeUndefined(); 171fb726d48Sopenharmony_ci }); 172fb726d48Sopenharmony_ci 173fb726d48Sopenharmony_ci it('LitTableTest09', () => { 174fb726d48Sopenharmony_ci expect(litTable.dataSource).not.toBeUndefined(); 175fb726d48Sopenharmony_ci }); 176fb726d48Sopenharmony_ci 177fb726d48Sopenharmony_ci it('LitTableTest10', () => { 178fb726d48Sopenharmony_ci expect(litTable.recycleDataSource).not.toBeUndefined(); 179fb726d48Sopenharmony_ci }); 180fb726d48Sopenharmony_ci 181fb726d48Sopenharmony_ci it('LitTableTest11', () => { 182fb726d48Sopenharmony_ci expect(litTable.meauseElementHeight()).toBe(27); 183fb726d48Sopenharmony_ci }); 184fb726d48Sopenharmony_ci 185fb726d48Sopenharmony_ci it('LitTableTest12', () => { 186fb726d48Sopenharmony_ci expect(litTable.meauseTreeElementHeight()).toBe(27); 187fb726d48Sopenharmony_ci }); 188fb726d48Sopenharmony_ci 189fb726d48Sopenharmony_ci it('LitTableTest13', () => { 190fb726d48Sopenharmony_ci document.body.innerHTML = "<lit-table id='tab' tree></lit-table>"; 191fb726d48Sopenharmony_ci let table = document.querySelector('#tab') as LitTable; 192fb726d48Sopenharmony_ci let htmlElement = document.createElement('lit-table-column') as LitTableColumn; 193fb726d48Sopenharmony_ci htmlElement.setAttribute('title', '1'); 194fb726d48Sopenharmony_ci htmlElement.setAttribute('data-index', '1'); 195fb726d48Sopenharmony_ci htmlElement.setAttribute('key', '1'); 196fb726d48Sopenharmony_ci htmlElement.setAttribute('align', 'flex-start'); 197fb726d48Sopenharmony_ci htmlElement.setAttribute('height', '32px'); 198fb726d48Sopenharmony_ci table!.appendChild(htmlElement); 199fb726d48Sopenharmony_ci setTimeout(() => { 200fb726d48Sopenharmony_ci table.recycleDataSource = [ 201fb726d48Sopenharmony_ci { 202fb726d48Sopenharmony_ci id: 1, 203fb726d48Sopenharmony_ci name: 'name', 204fb726d48Sopenharmony_ci }, 205fb726d48Sopenharmony_ci { 206fb726d48Sopenharmony_ci id: 2, 207fb726d48Sopenharmony_ci name: 'nameValue', 208fb726d48Sopenharmony_ci }, 209fb726d48Sopenharmony_ci ]; 210fb726d48Sopenharmony_ci expect(table.meauseTreeElementHeight()).toBe(27); 211fb726d48Sopenharmony_ci }, 20); 212fb726d48Sopenharmony_ci }); 213fb726d48Sopenharmony_ci 214fb726d48Sopenharmony_ci it('LitTableTest14', () => { 215fb726d48Sopenharmony_ci expect(litTable.createExpandBtn({ expanded: false, data: { status: true } })).not.toBeUndefined(); 216fb726d48Sopenharmony_ci }); 217fb726d48Sopenharmony_ci 218fb726d48Sopenharmony_ci it('LitTableTest15', () => { 219fb726d48Sopenharmony_ci let newTableElement = document.createElement('div'); 220fb726d48Sopenharmony_ci newTableElement.classList.add('tr'); 221fb726d48Sopenharmony_ci newTableElement.style.cursor = 'pointer'; 222fb726d48Sopenharmony_ci newTableElement.style.gridTemplateColumns = '1,2,3'; 223fb726d48Sopenharmony_ci newTableElement.style.position = 'absolute'; 224fb726d48Sopenharmony_ci newTableElement.style.top = '0px'; 225fb726d48Sopenharmony_ci newTableElement.style.left = '0px'; 226fb726d48Sopenharmony_ci litTable.currentRecycleList = [newTableElement]; 227fb726d48Sopenharmony_ci litTable.recycleDs = [{ rowHidden: false, data: { isSearch: true } }]; 228fb726d48Sopenharmony_ci litTable.tbodyElement = document.createElement('div'); 229fb726d48Sopenharmony_ci litTable.treeElement = document.createElement('div'); 230fb726d48Sopenharmony_ci litTable.tableElement = document.createElement('div'); 231fb726d48Sopenharmony_ci litTable.theadElement = document.createElement('div'); 232fb726d48Sopenharmony_ci expect(litTable.reMeauseHeight()).toBeUndefined(); 233fb726d48Sopenharmony_ci }); 234fb726d48Sopenharmony_ci 235fb726d48Sopenharmony_ci it('LitTableTest15', () => { 236fb726d48Sopenharmony_ci const rowData = { 237fb726d48Sopenharmony_ci data: [ 238fb726d48Sopenharmony_ci { 239fb726d48Sopenharmony_ci isSelected: undefined, 240fb726d48Sopenharmony_ci }, 241fb726d48Sopenharmony_ci ], 242fb726d48Sopenharmony_ci }; 243fb726d48Sopenharmony_ci litTable.columns.forEach = jest.fn(() => true); 244fb726d48Sopenharmony_ci expect(litTable.createNewTableElement(rowData)).not.toBeUndefined(); 245fb726d48Sopenharmony_ci }); 246fb726d48Sopenharmony_ci 247fb726d48Sopenharmony_ci it('LitTableTest16', () => { 248fb726d48Sopenharmony_ci let element = document.createElement('div'); 249fb726d48Sopenharmony_ci let ch = document.createElement('div'); 250fb726d48Sopenharmony_ci element.appendChild(ch); 251fb726d48Sopenharmony_ci let rowObject = { rowHidden: false, data: { isSearch: true } }; 252fb726d48Sopenharmony_ci let tableColmn = document.createElement('lit-table-column') as LitTableColumn; 253fb726d48Sopenharmony_ci tableColmn.setAttribute('data-index', '1'); 254fb726d48Sopenharmony_ci tableColmn.setAttribute('title', '1'); 255fb726d48Sopenharmony_ci tableColmn.setAttribute('data-index', '2'); 256fb726d48Sopenharmony_ci tableColmn.setAttribute('align', 'flex-start'); 257fb726d48Sopenharmony_ci tableColmn.setAttribute('height', '32px'); 258fb726d48Sopenharmony_ci tableColmn.setAttribute('key', '2'); 259fb726d48Sopenharmony_ci let tableColmn1 = document.createElement('lit-table-column') as LitTableColumn; 260fb726d48Sopenharmony_ci tableColmn1.setAttribute('align', 'flex-start'); 261fb726d48Sopenharmony_ci tableColmn1.setAttribute('height', '32px'); 262fb726d48Sopenharmony_ci tableColmn1.setAttribute('title', '2'); 263fb726d48Sopenharmony_ci tableColmn1.setAttribute('data-index', '2'); 264fb726d48Sopenharmony_ci tableColmn1.setAttribute('key', '2'); 265fb726d48Sopenharmony_ci litTable.columns = [tableColmn, tableColmn1]; 266fb726d48Sopenharmony_ci expect(litTable.freshCurrentLine(element, rowObject)).toBeUndefined(); 267fb726d48Sopenharmony_ci }); 268fb726d48Sopenharmony_ci 269fb726d48Sopenharmony_ci it('LitTableTest16', () => { 270fb726d48Sopenharmony_ci litTable.recycleDs.length = 1; 271fb726d48Sopenharmony_ci litTable.setCurrentSelection = jest.fn(() => true); 272fb726d48Sopenharmony_ci expect(litTable.scrollToData()).toBeUndefined(); 273fb726d48Sopenharmony_ci }); 274fb726d48Sopenharmony_ci 275fb726d48Sopenharmony_ci it('LitTableTest17', () => { 276fb726d48Sopenharmony_ci litTable.recycleDs = [{ rowHidden: false, data: { isSearch: true } }]; 277fb726d48Sopenharmony_ci let dataSource = [ 278fb726d48Sopenharmony_ci { 279fb726d48Sopenharmony_ci id: 11, 280fb726d48Sopenharmony_ci name: 'name', 281fb726d48Sopenharmony_ci }, 282fb726d48Sopenharmony_ci { 283fb726d48Sopenharmony_ci id: 21, 284fb726d48Sopenharmony_ci name: 'value', 285fb726d48Sopenharmony_ci }, 286fb726d48Sopenharmony_ci ]; 287fb726d48Sopenharmony_ci expect(litTable.expandList(dataSource)).toBeUndefined(); 288fb726d48Sopenharmony_ci }); 289fb726d48Sopenharmony_ci 290fb726d48Sopenharmony_ci it('LitTableTest18', () => { 291fb726d48Sopenharmony_ci expect(litTable.clearAllSelection()).toBeUndefined(); 292fb726d48Sopenharmony_ci }); 293fb726d48Sopenharmony_ci 294fb726d48Sopenharmony_ci it('LitTableTest19', () => { 295fb726d48Sopenharmony_ci const mockEvent = new MouseEvent('click', { button: 0 }); 296fb726d48Sopenharmony_ci expect(() => litTable.dispatchRowClickEvent({ data: { isSelected: '' } }, [], mockEvent)).not.toThrow(); 297fb726d48Sopenharmony_ci }); 298fb726d48Sopenharmony_ci 299fb726d48Sopenharmony_ci it('LitTableTest20', () => { 300fb726d48Sopenharmony_ci litTable.treeElement = jest.fn(() => undefined); 301fb726d48Sopenharmony_ci litTable.treeElement.children = jest.fn(() => [1]); 302fb726d48Sopenharmony_ci litTable.columns.forEach = jest.fn(() => true); 303fb726d48Sopenharmony_ci litTable.treeElement.lastChild = jest.fn(() => true); 304fb726d48Sopenharmony_ci litTable.treeElement.lastChild.style = jest.fn(() => true); 305fb726d48Sopenharmony_ci expect(litTable.createNewTreeTableElement({ data: '' })).not.toBeUndefined(); 306fb726d48Sopenharmony_ci }); 307fb726d48Sopenharmony_ci 308fb726d48Sopenharmony_ci it('LitTableTest21', () => { 309fb726d48Sopenharmony_ci litTable.tableElement = jest.fn(() => undefined); 310fb726d48Sopenharmony_ci litTable.tableElement.scrollTop = jest.fn(() => 1); 311fb726d48Sopenharmony_ci expect(litTable.move1px()).toBeUndefined(); 312fb726d48Sopenharmony_ci }); 313fb726d48Sopenharmony_ci 314fb726d48Sopenharmony_ci it('LitTableTest22', () => { 315fb726d48Sopenharmony_ci document.body.innerHTML = `<lit-table id="aaa"></lit-table>`; 316fb726d48Sopenharmony_ci let litTable = document.querySelector('#aaa') as LitTable; 317fb726d48Sopenharmony_ci expect(litTable.setMouseIn(true, [])).toBeUndefined(); 318fb726d48Sopenharmony_ci }); 319fb726d48Sopenharmony_ci 320fb726d48Sopenharmony_ci it('LitTableTest23', () => { 321fb726d48Sopenharmony_ci let tableIcon = document.createElement('lit-icon') as LitIcon; 322fb726d48Sopenharmony_ci let mouseClickEvent: MouseEvent = new MouseEvent('click', <MouseEventInit>{ movementX: 1, movementY: 2 }); 323fb726d48Sopenharmony_ci tableIcon.dispatchEvent(mouseClickEvent); 324fb726d48Sopenharmony_ci }); 325fb726d48Sopenharmony_ci 326fb726d48Sopenharmony_ci it('LitTableTest24', () => { 327fb726d48Sopenharmony_ci document.body.innerHTML = `<lit-table id="aaa"></lit-table>`; 328fb726d48Sopenharmony_ci let litTable = document.querySelector('#aaa') as LitTable; 329fb726d48Sopenharmony_ci const data = { 330fb726d48Sopenharmony_ci isSelected: true, 331fb726d48Sopenharmony_ci }; 332fb726d48Sopenharmony_ci expect(litTable.setCurrentSelection(data)).toBeUndefined(); 333fb726d48Sopenharmony_ci }); 334fb726d48Sopenharmony_ci 335fb726d48Sopenharmony_ci it('LitTableTest25', () => { 336fb726d48Sopenharmony_ci document.body.innerHTML = `<lit-table id="aaa"></lit-table>`; 337fb726d48Sopenharmony_ci let litTable = document.querySelector('#aaa') as LitTable; 338fb726d48Sopenharmony_ci litTable.formatName = true; 339fb726d48Sopenharmony_ci expect(litTable.formatName).toBeTruthy(); 340fb726d48Sopenharmony_ci }); 341fb726d48Sopenharmony_ci 342fb726d48Sopenharmony_ci it('LitTableTest26', () => { 343fb726d48Sopenharmony_ci let litTable = new LitTable(); 344fb726d48Sopenharmony_ci expect(litTable.dataExportInit()).toBeUndefined(); 345fb726d48Sopenharmony_ci }); 346fb726d48Sopenharmony_ci it('LitTableTest27', () => { 347fb726d48Sopenharmony_ci let litTable = new LitTable(); 348fb726d48Sopenharmony_ci let htmlElement = document.createElement('lit-table-column') as LitTableColumn; 349fb726d48Sopenharmony_ci htmlElement.setAttribute('title', '41'); 350fb726d48Sopenharmony_ci htmlElement.setAttribute('data-index', '1'); 351fb726d48Sopenharmony_ci htmlElement.setAttribute('key', '14'); 352fb726d48Sopenharmony_ci htmlElement.setAttribute('align', 'flex-start'); 353fb726d48Sopenharmony_ci htmlElement.setAttribute('height', '34px'); 354fb726d48Sopenharmony_ci litTable.columns = [htmlElement]; 355fb726d48Sopenharmony_ci document.body.innerHTML = `<lit-table id="aaa"> <lit-progress-bar id="export_progress_bar" class="progress"></lit-progress-bar></lit-table>`; 356fb726d48Sopenharmony_ci let progressBar = document.querySelector('#export_progress_bar') as LitProgressBar; 357fb726d48Sopenharmony_ci litTable.exportProgress = progressBar; 358fb726d48Sopenharmony_ci expect(litTable.exportData()).toBeUndefined(); 359fb726d48Sopenharmony_ci }); 360fb726d48Sopenharmony_ci 361fb726d48Sopenharmony_ci it('LitTableTest28', () => { 362fb726d48Sopenharmony_ci expect(litTable.formatExportData()).not.toBeUndefined(); 363fb726d48Sopenharmony_ci }); 364fb726d48Sopenharmony_ci 365fb726d48Sopenharmony_ci it('LitTableTest29', () => { 366fb726d48Sopenharmony_ci expect(litTable.setSelectedRow(true, [])).toBeUndefined(); 367fb726d48Sopenharmony_ci }); 368fb726d48Sopenharmony_ci 369fb726d48Sopenharmony_ci it('LitTableTest30', () => { 370fb726d48Sopenharmony_ci document.body.innerHTML = `<lit-table id="aaa"></lit-table>`; 371fb726d48Sopenharmony_ci let litTable = document.querySelector('#aaa') as LitTable; 372fb726d48Sopenharmony_ci litTable.setAttribute('tree', true); 373fb726d48Sopenharmony_ci expect(litTable.dataSource).toStrictEqual([]); 374fb726d48Sopenharmony_ci }); 375fb726d48Sopenharmony_ci 376fb726d48Sopenharmony_ci it('LitTableTest31', () => { 377fb726d48Sopenharmony_ci document.body.innerHTML = `<lit-table id="aaa"></lit-table>`; 378fb726d48Sopenharmony_ci let litTable = document.querySelector('#aaa') as LitTable; 379fb726d48Sopenharmony_ci litTable.rememberScrollTop = true; 380fb726d48Sopenharmony_ci expect(litTable.recycleDataSource).toStrictEqual([]); 381fb726d48Sopenharmony_ci }); 382fb726d48Sopenharmony_ci 383fb726d48Sopenharmony_ci it('LitTableTest32', () => { 384fb726d48Sopenharmony_ci let litTable = new LitTable(); 385fb726d48Sopenharmony_ci expect(litTable.dataExportInit()).toBeUndefined(); 386fb726d48Sopenharmony_ci }); 387fb726d48Sopenharmony_ci 388fb726d48Sopenharmony_ci it('LitTableTest33', () => { 389fb726d48Sopenharmony_ci let tableColmn = document.createElement('lit-table-column') as LitTableColumn; 390fb726d48Sopenharmony_ci tableColmn.setAttribute('title', '21'); 391fb726d48Sopenharmony_ci tableColmn.setAttribute('data-index', '13'); 392fb726d48Sopenharmony_ci tableColmn.setAttribute('key', '4'); 393fb726d48Sopenharmony_ci tableColmn.setAttribute('align', 'flex-start'); 394fb726d48Sopenharmony_ci tableColmn.setAttribute('height', '32px'); 395fb726d48Sopenharmony_ci let tableColmn1 = document.createElement('lit-table-column') as LitTableColumn; 396fb726d48Sopenharmony_ci tableColmn1.setAttribute('title', '52'); 397fb726d48Sopenharmony_ci tableColmn1.setAttribute('data-index', '244'); 398fb726d48Sopenharmony_ci tableColmn1.setAttribute('key', '25'); 399fb726d48Sopenharmony_ci tableColmn1.setAttribute('align', 'flex-start'); 400fb726d48Sopenharmony_ci tableColmn1.setAttribute('height', '24px'); 401fb726d48Sopenharmony_ci 402fb726d48Sopenharmony_ci let tableColmn2 = document.createElement('lit-table-column') as LitTableColumn; 403fb726d48Sopenharmony_ci tableColmn2.setAttribute('title', '53'); 404fb726d48Sopenharmony_ci tableColmn2.setAttribute('data-index', '35'); 405fb726d48Sopenharmony_ci tableColmn2.setAttribute('key', '35'); 406fb726d48Sopenharmony_ci tableColmn2.setAttribute('align', 'flex-start'); 407fb726d48Sopenharmony_ci tableColmn2.setAttribute('height', '325px'); 408fb726d48Sopenharmony_ci litTable.columns = [tableColmn, tableColmn1, tableColmn2]; 409fb726d48Sopenharmony_ci let dataSource = [ 410fb726d48Sopenharmony_ci { 411fb726d48Sopenharmony_ci id: 22, 412fb726d48Sopenharmony_ci name: 'name', 413fb726d48Sopenharmony_ci }, 414fb726d48Sopenharmony_ci { 415fb726d48Sopenharmony_ci id: 12, 416fb726d48Sopenharmony_ci name: 'nameValue', 417fb726d48Sopenharmony_ci }, 418fb726d48Sopenharmony_ci ]; 419fb726d48Sopenharmony_ci expect(litTable.formatExportData(dataSource)).toBeTruthy(); 420fb726d48Sopenharmony_ci }); 421fb726d48Sopenharmony_ci 422fb726d48Sopenharmony_ci it('LitTableTest34', () => { 423fb726d48Sopenharmony_ci let list = [ 424fb726d48Sopenharmony_ci { 425fb726d48Sopenharmony_ci memoryTap: 'All Heap', 426fb726d48Sopenharmony_ci existing: 1481, 427fb726d48Sopenharmony_ci existingString: '44.89 Kb', 428fb726d48Sopenharmony_ci freeByteString: '42.54 Kb', 429fb726d48Sopenharmony_ci allocCount: 461, 430fb726d48Sopenharmony_ci freeCount: 103, 431fb726d48Sopenharmony_ci freeByte: 43451, 432fb726d48Sopenharmony_ci totalBytes: 641, 433fb726d48Sopenharmony_ci totalBytesString: '4.44 Kb', 434fb726d48Sopenharmony_ci maxStr: '275 byte', 435fb726d48Sopenharmony_ci max: 264, 436fb726d48Sopenharmony_ci totalCount: 149, 437fb726d48Sopenharmony_ci existingValue: [1948, 411, 51820], 438fb726d48Sopenharmony_ci }, 439fb726d48Sopenharmony_ci ]; 440fb726d48Sopenharmony_ci LitTable.createNewTreeTableElement = jest.fn().mockResolvedValue({}); 441fb726d48Sopenharmony_ci litTable.treeElement = document.createElement('div'); 442fb726d48Sopenharmony_ci litTable.tableElement = document.createElement('div'); 443fb726d48Sopenharmony_ci litTable.setAttribute('selectable', '123'); 444fb726d48Sopenharmony_ci litTable.setAttribute('tree', ''); 445fb726d48Sopenharmony_ci litTable.recycleDataSource = [ 446fb726d48Sopenharmony_ci { 447fb726d48Sopenharmony_ci id: 1, 448fb726d48Sopenharmony_ci name: 'name', 449fb726d48Sopenharmony_ci }, 450fb726d48Sopenharmony_ci { 451fb726d48Sopenharmony_ci id: 2, 452fb726d48Sopenharmony_ci name: 'nameValue', 453fb726d48Sopenharmony_ci }, 454fb726d48Sopenharmony_ci ]; 455fb726d48Sopenharmony_ci let tableColmn = document.createElement('lit-table-column') as LitTableColumn; 456fb726d48Sopenharmony_ci tableColmn.setAttribute('title', '6'); 457fb726d48Sopenharmony_ci tableColmn.setAttribute('data-index', '22'); 458fb726d48Sopenharmony_ci tableColmn.setAttribute('key', '29'); 459fb726d48Sopenharmony_ci tableColmn.setAttribute('align', 'flex-start'); 460fb726d48Sopenharmony_ci tableColmn.setAttribute('height', '42px'); 461fb726d48Sopenharmony_ci let tableColmn1 = document.createElement('lit-table-column') as LitTableColumn; 462fb726d48Sopenharmony_ci tableColmn1.setAttribute('title', '125'); 463fb726d48Sopenharmony_ci tableColmn1.setAttribute('data-index', '22'); 464fb726d48Sopenharmony_ci tableColmn1.setAttribute('key', '12'); 465fb726d48Sopenharmony_ci tableColmn1.setAttribute('align', 'flex-start'); 466fb726d48Sopenharmony_ci tableColmn1.setAttribute('height', '121px'); 467fb726d48Sopenharmony_ci let tableColmn2 = document.createElement('lit-table-column') as LitTableColumn; 468fb726d48Sopenharmony_ci tableColmn2.setAttribute('title', '31'); 469fb726d48Sopenharmony_ci tableColmn2.setAttribute('data-index', '13'); 470fb726d48Sopenharmony_ci tableColmn2.setAttribute('key', '31'); 471fb726d48Sopenharmony_ci tableColmn2.setAttribute('align', 'flex-start'); 472fb726d48Sopenharmony_ci tableColmn2.setAttribute('height', '12px'); 473fb726d48Sopenharmony_ci litTable.columns = [tableColmn, tableColmn1, tableColmn2]; 474fb726d48Sopenharmony_ci litTable.tbodyElement = document.createElement('div'); 475fb726d48Sopenharmony_ci litTable.theadElement = document.createElement('div'); 476fb726d48Sopenharmony_ci expect(litTable.meauseTreeRowElement(list)).toBeTruthy(); 477fb726d48Sopenharmony_ci }); 478fb726d48Sopenharmony_ci 479fb726d48Sopenharmony_ci it('LitTableTest35', () => { 480fb726d48Sopenharmony_ci let list = [ 481fb726d48Sopenharmony_ci { 482fb726d48Sopenharmony_ci memoryTap: 'All Heap', 483fb726d48Sopenharmony_ci existing: 43482, 484fb726d48Sopenharmony_ci existingString: '6.89 Kb', 485fb726d48Sopenharmony_ci freeByteString: '76.54 Kb', 486fb726d48Sopenharmony_ci allocCount: 462, 487fb726d48Sopenharmony_ci freeCount: 103, 488fb726d48Sopenharmony_ci freeByte: 456, 489fb726d48Sopenharmony_ci totalBytes: 622, 490fb726d48Sopenharmony_ci totalBytesString: '6.44 Kb', 491fb726d48Sopenharmony_ci maxStr: '200 byte', 492fb726d48Sopenharmony_ci max: 222, 493fb726d48Sopenharmony_ci totalCount: 12, 494fb726d48Sopenharmony_ci existingValue: [1348, 6662, 2220], 495fb726d48Sopenharmony_ci }, 496fb726d48Sopenharmony_ci ]; 497fb726d48Sopenharmony_ci LitTable.createNewTreeTableElement = jest.fn().mockResolvedValue({}); 498fb726d48Sopenharmony_ci litTable.treeElement = document.createElement('div'); 499fb726d48Sopenharmony_ci litTable.tableElement = document.createElement('div'); 500fb726d48Sopenharmony_ci litTable.setAttribute('selectable', '123'); 501fb726d48Sopenharmony_ci let tableColmn = document.createElement('lit-table-column') as LitTableColumn; 502fb726d48Sopenharmony_ci tableColmn.setAttribute('title', '103'); 503fb726d48Sopenharmony_ci tableColmn.setAttribute('data-index', '13'); 504fb726d48Sopenharmony_ci tableColmn.setAttribute('key', '10'); 505fb726d48Sopenharmony_ci tableColmn.setAttribute('align', 'flex-start'); 506fb726d48Sopenharmony_ci tableColmn.setAttribute('height', '32px'); 507fb726d48Sopenharmony_ci let tableColmn1 = document.createElement('lit-table-column') as LitTableColumn; 508fb726d48Sopenharmony_ci tableColmn1.setAttribute('align', 'flex-start'); 509fb726d48Sopenharmony_ci tableColmn1.setAttribute('height', '32px'); 510fb726d48Sopenharmony_ci tableColmn1.setAttribute('title', '2'); 511fb726d48Sopenharmony_ci tableColmn1.setAttribute('data-index', '23'); 512fb726d48Sopenharmony_ci tableColmn1.setAttribute('key', '20'); 513fb726d48Sopenharmony_ci let tableColmn2 = document.createElement('lit-table-column') as LitTableColumn; 514fb726d48Sopenharmony_ci tableColmn2.setAttribute('title', '31'); 515fb726d48Sopenharmony_ci tableColmn2.setAttribute('key', '30'); 516fb726d48Sopenharmony_ci tableColmn2.setAttribute('align', 'flex-start'); 517fb726d48Sopenharmony_ci tableColmn2.setAttribute('data-index', '3'); 518fb726d48Sopenharmony_ci tableColmn2.setAttribute('height', '32px'); 519fb726d48Sopenharmony_ci litTable.columns = [tableColmn, tableColmn1, tableColmn2]; 520fb726d48Sopenharmony_ci litTable.theadElement = document.createElement('div'); 521fb726d48Sopenharmony_ci litTable.tbodyElement = document.createElement('div'); 522fb726d48Sopenharmony_ci expect(litTable.meauseAllRowHeight(list)).toBeTruthy(); 523fb726d48Sopenharmony_ci }); 524fb726d48Sopenharmony_ci 525fb726d48Sopenharmony_ci it('LitTableTest36', () => { 526fb726d48Sopenharmony_ci let tableColmn = document.createElement('lit-table-column') as LitTableColumn; 527fb726d48Sopenharmony_ci tableColmn.setAttribute('data-index', '14'); 528fb726d48Sopenharmony_ci tableColmn.setAttribute('key', '141'); 529fb726d48Sopenharmony_ci tableColmn.setAttribute('align', 'flex-start'); 530fb726d48Sopenharmony_ci tableColmn.setAttribute('height', '32px'); 531fb726d48Sopenharmony_ci tableColmn.setAttribute('title', '114'); 532fb726d48Sopenharmony_ci let tableColmn1 = document.createElement('lit-table-column') as LitTableColumn; 533fb726d48Sopenharmony_ci tableColmn1.setAttribute('key', '214'); 534fb726d48Sopenharmony_ci tableColmn1.setAttribute('align', 'flex-start'); 535fb726d48Sopenharmony_ci tableColmn1.setAttribute('title', '24'); 536fb726d48Sopenharmony_ci tableColmn1.setAttribute('data-index', '24'); 537fb726d48Sopenharmony_ci tableColmn1.setAttribute('height', '32px'); 538fb726d48Sopenharmony_ci let tableColmn2 = document.createElement('lit-table-column') as LitTableColumn; 539fb726d48Sopenharmony_ci tableColmn2.setAttribute('title', '34'); 540fb726d48Sopenharmony_ci tableColmn2.setAttribute('key', '314'); 541fb726d48Sopenharmony_ci tableColmn2.setAttribute('align', 'flex-start'); 542fb726d48Sopenharmony_ci tableColmn2.setAttribute('height', '32px'); 543fb726d48Sopenharmony_ci tableColmn2.setAttribute('data-index', '34'); 544fb726d48Sopenharmony_ci litTable.columns = [tableColmn, tableColmn1, tableColmn2]; 545fb726d48Sopenharmony_ci let dataSource = [ 546fb726d48Sopenharmony_ci { 547fb726d48Sopenharmony_ci id: 13, 548fb726d48Sopenharmony_ci name: 'name', 549fb726d48Sopenharmony_ci }, 550fb726d48Sopenharmony_ci { 551fb726d48Sopenharmony_ci id: 23, 552fb726d48Sopenharmony_ci name: 'nameValue', 553fb726d48Sopenharmony_ci }, 554fb726d48Sopenharmony_ci ]; 555fb726d48Sopenharmony_ci expect(litTable.formatExportCsvData(dataSource)).toBeTruthy(); 556fb726d48Sopenharmony_ci }); 557fb726d48Sopenharmony_ci 558fb726d48Sopenharmony_ci it('LitTableTest37', () => { 559fb726d48Sopenharmony_ci let element = document.createElement('div'); 560fb726d48Sopenharmony_ci litTable.tableElement = document.createElement('div'); 561fb726d48Sopenharmony_ci let firstElement = document.createElement('div'); 562fb726d48Sopenharmony_ci let ch = document.createElement('div'); 563fb726d48Sopenharmony_ci element.appendChild(ch); 564fb726d48Sopenharmony_ci let rowObject = { rowHidden: false, data: { isSearch: true } }; 565fb726d48Sopenharmony_ci let tableColmn = document.createElement('lit-table-column') as LitTableColumn; 566fb726d48Sopenharmony_ci tableColmn.setAttribute('height', '32px'); 567fb726d48Sopenharmony_ci tableColmn.setAttribute('title', '16'); 568fb726d48Sopenharmony_ci tableColmn.setAttribute('data-index', '1'); 569fb726d48Sopenharmony_ci tableColmn.setAttribute('align', 'flex-start'); 570fb726d48Sopenharmony_ci tableColmn.setAttribute('height', '36px'); 571fb726d48Sopenharmony_ci tableColmn.setAttribute('key', '1'); 572fb726d48Sopenharmony_ci let tableColmn1 = document.createElement('lit-table-column') as LitTableColumn; 573fb726d48Sopenharmony_ci tableColmn1.setAttribute('key', '2'); 574fb726d48Sopenharmony_ci tableColmn1.setAttribute('align', 'flex-start'); 575fb726d48Sopenharmony_ci tableColmn1.setAttribute('height', '32px'); 576fb726d48Sopenharmony_ci tableColmn1.setAttribute('title', '2'); 577fb726d48Sopenharmony_ci tableColmn1.setAttribute('data-index', '2'); 578fb726d48Sopenharmony_ci litTable.columns = [tableColmn, tableColmn1]; 579fb726d48Sopenharmony_ci expect(litTable.freshCurrentLine(element, rowObject, firstElement)).toBeUndefined(); 580fb726d48Sopenharmony_ci }); 581fb726d48Sopenharmony_ci it('LitTableTest38', () => { 582fb726d48Sopenharmony_ci litTable.hideDownload = true; 583fb726d48Sopenharmony_ci expect(litTable.hideDownload).toBeTruthy(); 584fb726d48Sopenharmony_ci }); 585fb726d48Sopenharmony_ci it('LitTableTest39', () => { 586fb726d48Sopenharmony_ci litTable.hideDownload = false; 587fb726d48Sopenharmony_ci expect(litTable.hideDownload).not.toBeUndefined(); 588fb726d48Sopenharmony_ci }); 589fb726d48Sopenharmony_ci it('LitTableTest40', () => { 590fb726d48Sopenharmony_ci expect(litTable.createBtn({ expanded: false, data: { status: true } })).not.toBeUndefined(); 591fb726d48Sopenharmony_ci }); 592fb726d48Sopenharmony_ci it('LitTableTest41', () => { 593fb726d48Sopenharmony_ci expect(litTable.mouseOut()).toBeUndefined(); 594fb726d48Sopenharmony_ci }); 595fb726d48Sopenharmony_ci it('LitTableTest42', () => { 596fb726d48Sopenharmony_ci litTable.isRecycleList = true; 597fb726d48Sopenharmony_ci expect(litTable.setCurrentHover({})).toBeUndefined(); 598fb726d48Sopenharmony_ci }); 599fb726d48Sopenharmony_ci it('LitTableTest43', () => { 600fb726d48Sopenharmony_ci expect(litTable.clearAllHover({})).toBeUndefined(); 601fb726d48Sopenharmony_ci }); 602fb726d48Sopenharmony_ci}); 603