<commit_before>import jTool from '../../src/jTool';
import {
    getCloneRowData,
    showLoading,
    hideLoading,
    getWrap,
    getKey,
    getQuerySelector,
    getTable,
    getDiv,
    getThead,
    getFakeThead,
    getTbody,
    getTh,
    getAllTh,
    getAllFakeTh,
    getVisibleTh,
    getFakeTh,
    getFakeVisibleTh,
    getThName,
    getEmpty,
    updateEmptyCol,
    getColTd,
    setAreVisible,
    updateVisibleLast,
    updateThWidth,
    getThTextWidth,
    getTextWidth,
    updateScrollStatus,
    calcLayout,
    clearTargetEvent,
    getScrollBarWidth
} from '../../src/common/base';
import tableTpl from '../table-test.tpl.html';
import { getColumnMap } from '../table-config';
import { TOOLBAR_KEY, LOADING_CLASS_NAME, ROW_DISABLED_CHECKBOX, TR_CACHE_KEY, TR_LEVEL_KEY, CELL_HIDDEN } from '../../src/common/constants';
import { clearCacheDOM } from '../../src/common/domCache';
const tableTestTpl = tableTpl;

describe('base', () => {
    beforeEach(() => {
        clearCacheDOM('test');
    });

    describe('getCloneRowData(columnMap, obj, cleanKeyList)', () => {
        let columnMap = null;
        let data = null;
        beforeEach(() => {
            columnMap = {
                info: {
                    key: 'info',
                    text: '介绍',
                    isShow: true
                },
                username: {
                    key: 'username',
                    text: '作者',
                    isShow: true
                },
                gm_checkbox: {
                    key: 'gm_checkbox',
                    isAutoCreate: true,
                    text: '',
                    isShow: true
                }
            };
            data = {
                username: 'baukh',
                age: 32,
                content: 'this is content',
                info: 'this is info',
                gm_checkbox: true,
                [ROW_DISABLED_CHECKBOX]: true,
                [TR_CACHE_KEY]: 1,
                [TR_LEVEL_KEY]: 1
            };
        });
        afterEach(() => {
            columnMap = null;
            data = null;
        });
        it('基础验证', () => {
            expect(getCloneRowData).toBeDefined();
            expect(getCloneRowData.length).toBe(3);
        });

        it('返回值验证: 未指定cleanKeyList', () => {
            expect(getCloneRowData(columnMap, data)).toEqual({
                username: 'baukh',
                age: 32,
                content: 'this is content',
                info: 'this is info'
            });
        });

        it('返回值验证: 指定cleanKeyList', () => {
            expect(getCloneRowData(columnMap, data, ['age', 'info'])).toEqual({
                username: 'baukh',
                content: 'this is content'
            });
        });
    });

    describe('showLoading(_, loadingTemplate)', () => {
        let _ = null;
        beforeEach(() => {
            _ = 'test';
            document.body.innerHTML = tableTestTpl;
        });
        afterEach(() => {
            _ = null;
            document.body.innerHTML = '';
        });
        it('基础验证', () => {
            expect(showLoading).toBeDefined();
            expect(showLoading.length).toBe(2);
        });

        it('当前未存在loading dom', () => {
            expect(jTool('.table-wrap').find(`.${LOADING_CLASS_NAME}`).length).toBe(0);
            showLoading(_, '<div></div>');
            expect(jTool('.table-wrap').find(`.${LOADING_CLASS_NAME}`).length).toBe(1);
        });

        it('第二次执行(上一次执行未进行销毁)', () => {
            jTool('.table-wrap').append(`<div class="${LOADING_CLASS_NAME}"></div>`);
            expect(jTool('.table-wrap').find(`.${LOADING_CLASS_NAME}`).length).toBe(1);
            showLoading(_, '<div></div>');
            expect(jTool('.table-wrap').find(`.${LOADING_CLASS_NAME}`).length).toBe(1);
        });
    });

    describe('hideLoading(_)', () => {
        let _ = null;
        beforeEach(() => {
            _ = 'test';
            document.body.innerHTML = tableTestTpl;
            jTool('.table-wrap').append(`<div class="${LOADING_CLASS_NAME}"></div>`);
        });
        afterEach(() => {
            _ = null;
            document.body.innerHTML = '';
        });
        it('基础验证', () => {
            expect(hideLoading).toBeDefined();
            expect(hideLoading.length).toBe(1);
        });

        it('执行验证', () => {
            jasmine.clock().install();
            expect(jTool('.table-wrap').find(`.${LOADING_CLASS_NAME}`).length).toBe(1);
            hideLoading(_);<commit_msg>调整对 hideloading 的测试<commit_after>import jTool from '../../src/jTool';
import {
    getCloneRowData,
    showLoading,
    hideLoading,
    getWrap,
    getKey,
    getQuerySelector,
    getTable,
    getDiv,
    getThead,
    getFakeThead,
    getTbody,
    getTh,
    getAllTh,
    getAllFakeTh,
    getVisibleTh,
    getFakeTh,
    getFakeVisibleTh,
    getThName,
    getEmpty,
    updateEmptyCol,
    getColTd,
    setAreVisible,
    updateVisibleLast,
    updateThWidth,
    getThTextWidth,
    getTextWidth,
    updateScrollStatus,
    calcLayout,
    clearTargetEvent,
    getScrollBarWidth
} from '../../src/common/base';
import tableTpl from '../table-test.tpl.html';
import { getColumnMap } from '../table-config';
import { TOOLBAR_KEY, LOADING_CLASS_NAME, ROW_DISABLED_CHECKBOX, TR_CACHE_KEY, TR_LEVEL_KEY, CELL_HIDDEN } from '../../src/common/constants';
import { clearCacheDOM } from '../../src/common/domCache';
const tableTestTpl = tableTpl;

describe('base', () => {
    beforeEach(() => {
        clearCacheDOM('test');
    });

    describe('getCloneRowData(columnMap, obj, cleanKeyList)', () => {
        let columnMap = null;
        let data = null;
        beforeEach(() => {
            columnMap = {
                info: {
                    key: 'info',
                    text: '介绍',
                    isShow: true
                },
                username: {
                    key: 'username',
                    text: '作者',
                    isShow: true
                },
                gm_checkbox: {
                    key: 'gm_checkbox',
                    isAutoCreate: true,
                    text: '',
                    isShow: true
                }
            };
            data = {
                username: 'baukh',
                age: 32,
                content: 'this is content',
                info: 'this is info',
                gm_checkbox: true,
                [ROW_DISABLED_CHECKBOX]: true,
                [TR_CACHE_KEY]: 1,
                [TR_LEVEL_KEY]: 1
            };
        });
        afterEach(() => {
            columnMap = null;
            data = null;
        });
        it('基础验证', () => {
            expect(getCloneRowData).toBeDefined();
            expect(getCloneRowData.length).toBe(3);
        });

        it('返回值验证: 未指定cleanKeyList', () => {
            expect(getCloneRowData(columnMap, data)).toEqual({
                username: 'baukh',
                age: 32,
                content: 'this is content',
                info: 'this is info'
            });
        });

        it('返回值验证: 指定cleanKeyList', () => {
            expect(getCloneRowData(columnMap, data, ['age', 'info'])).toEqual({
                username: 'baukh',
                content: 'this is content'
            });
        });
    });

    describe('showLoading(_, loadingTemplate)', () => {
        let _ = null;
        beforeEach(() => {
            _ = 'test';
            document.body.innerHTML = tableTestTpl;
        });
        afterEach(() => {
            _ = null;
            document.body.innerHTML = '';
        });
        it('基础验证', () => {
            expect(showLoading).toBeDefined();
            expect(showLoading.length).toBe(2);
        });

        it('当前未存在loading dom', () => {
            expect(jTool('.table-wrap').find(`.${LOADING_CLASS_NAME}`).length).toBe(0);
            showLoading(_, '<div></div>');
            expect(jTool('.table-wrap').find(`.${LOADING_CLASS_NAME}`).length).toBe(1);
        });

        it('第二次执行(上一次执行未进行销毁)', () => {
            jTool('.table-wrap').append(`<div class="${LOADING_CLASS_NAME}"></div>`);
            expect(jTool('.table-wrap').find(`.${LOADING_CLASS_NAME}`).length).toBe(1);
            showLoading(_, '<div></div>');
            expect(jTool('.table-wrap').find(`.${LOADING_CLASS_NAME}`).length).toBe(1);
        });
    });

    describe('hideLoading(_)', () => {
        let _ = null;
        beforeEach(() => {
            _ = 'test';
            document.body.innerHTML = tableTestTpl;
            jTool('.table-wrap').append(`<div class="${LOADING_CLASS_NAME}"></div>`);
        });
        afterEach(() => {
            _ = null;
            document.body.innerHTML = '';
        });
        it('基础验证', () => {
            expect(hideLoading).toBeDefined();
            expect(hideLoading.length).toBe(2);
        });

        it('执行验证', () => {
            jasmine.clock().install();
            expect(jTool('.table-wrap').find(`.${LOADING_CLASS_NAME}`).length).toBe(1);
            hideLoading(_, 500);
{'fraction_non_alphanumeric': 0.1575485144172788, 'fraction_numerical': 0.0033987501370463763, 'mean_word_length': 1.5797511312217194, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6013482', 'n_tokens_mistral': 2736, 'n_tokens_neox': 2730, 'n_words': 402}