<commit_before>/**
 * @file 提示层测试用例
 * @author xiaowu
 */

/* globals zui */
describe('Tips', function () {
    var types = [
        '',
        0,
        false,
        true,
        1,
        null,
        undefined,
        function () {},
        {},
        []
    ];

    var guid = 0;
    var getGuid = function () {
        guid += 1;
        return 'zui-tips-' + guid;
    };

    afterEach(function () {
        $('.zui-tips-wrap').remove();
    });

    it('zui.Tips', function () {
        expect(typeof zui.Tips).toBe('function');
    });

    it('zui.Tips()', function () {
        var flag = true;
        try {
            var tips = zui.Tips;
            tips();
        }
        catch (e) {
            flag = false;
        }

        expect(flag).toBe(false);
    });

    it('check params', function () {
        var flag = true;

        try {
            types.forEach(function (key) {
                new zui.Tips(key);
            });
        }
        catch (e) {
            flag = false;
        }

        expect(flag).toBe(true);
    });

    it('zui.Tips(str)', function () {
        var str = getGuid();

        new zui.Tips(str);
        expect($('.zui-tips-wrap').html().indexOf(str) > -1).toBe(true);
    });

    it('zui.Tips({content: str})', function () {
        var str = getGuid();

        new zui.Tips({
            content: str
        });

        expect($('.zui-tips-wrap').html().indexOf(str) > -1).toBe(true);
    });


    // lock=true
    // autoClose=true
    // _timer=true
    // _closed<commit_msg>update: 更新测试case<commit_after>/**
 * @file 提示层测试用例
 * @author xiaowu
 */

/* globals zui */
describe('Tips', function () {
    var types = [
        '',
        0,
        false,
        true,
        1,
        null,
        undefined,
        function () {},
        {},
        []
    ];

    var guid = 0;
    var getGuid = function () {
        guid += 1;
        return 'zui-tips-' + guid;
    };

    afterEach(function () {
        $('.zui-tips-wrap').remove();
    });

    it('zui.Tips', function () {
        expect(typeof zui.Tips).toBe('function');
    });

    it('zui.Tips()', function () {
        var flag = true;
        try {
            var tips = zui.Tips;
            tips();
        }
        catch (e) {
            flag = false;
        }

        expect(flag).toBe(false);
    });

    it('check params', function () {
        var flag = true;

        try {
            types.forEach(function (key) {
                new zui.Tips(key);
            });
        }
        catch (e) {
            flag = false;
        }

        expect(flag).toBe(true);
    });

    it('zui.Tips(str)', function () {
        var str = getGuid();

        new zui.Tips(str);
        expect($('.zui-tips-wrap').html().indexOf(str) > -1).toBe(true);
    });

    it('{content: str}', function () {
        var str = getGuid();

        new zui.Tips({
            content: str
        });

        expect($('.zui-tips-wrap').html().indexOf(str) > -1).toBe(true);
    });

    it('autoClose: true', function (done) {
        var app =new zui.Tips({
            autoClose: true
        });

        expect(typeof app._timer).toBe('number');

        setTimeout(function () {
            expect($('.zui-tips-wrap').length).toBe(0);
            done();
        }, app.options.time + 500);
    });

    it('autoClose: false', function (done) {
        new zui.Tips({
            autoClose: false,
            time: 200
        });

        expect($('.zui-tips-wrap').length).toBe(1);

        setTimeout(function() {
            expect($('.zui-tips-wrap').length).toBe(1);
            done();
        }, 200 + 500 + 200);
    });

    it('time: 200', function (done) {
        new zui.Tips({
            autoClose: true,
            time: 200
        });

        expect($('.zui-tips-wrap').length).toBe(1);

        setTimeout(function () {
            expect($('.zui-tips-wrap').length).toBe(0);
            done();
        }, 200 + 500);
    });

    it('{lock: true}', function () {
        new zui.Tips({
            lock: true
        });

        expect($('.zui-tips-wrap.zui-tips-wrap-mask').length).toBe(1);
    });

    it('close()', function (done) {
        var app = new zui.Tips({
            autoClose: false
        });

        expect($('.zui-tips-wrap').length).toBe(1);

        app.close();

        setTimeout(function () {
            expect($('.zui-tips-wrap').length).toBe(0);
            done();
        }, 500);
    });

    it('close().close()', function () {
        var flag = true;

        try {
            new zui.Tips().close().close().close().close();
        }
        catch (e) {
            flag = false;
        }

        expect(flag).toBe(true);
    });

    it('autoClose => close()', function (done) {
        var app = new zui.Tips({
            autoClose: true,
            time: 500
        });

        setTimeout(function () {
            var flag = true;
            try {
                app.close().close();
            }
            catch (e) {
                flag = false;
            }
            expect(flag).toBe(true);
            done();
        }, 500 + 500);
    });

    it('close() => autoClose', function (done) {
        var app = new zui.Tips({
            autoClose: true,
            time: 500
        });

        app.close();

        setTimeout(function () {
            expect(app._closed).toBe(true);
            done();
        }, 500 + 500);
    });

    // lock=true
    // autoClose=true
    // _timer=true
    // _closed
{'fraction_non_alphanumeric': 0.1787257019438445, 'fraction_numerical': 0.012239020878329733, 'mean_word_length': 1.3280268118977796, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1260029', 'n_tokens_mistral': 1824, 'n_tokens_neox': 1731, 'n_words': 312}