/**
 * @file 对话框基类测试
 * @author schoeu1110@gmail.com
 */
define([
    'dialog/dialog',
    'zepto'
], function (Dialog, $) {
    'use strict';

    describe('dialog/dialog', function () {
        afterEach(function () {
            $('.zui-dialog-musk').remove();
        });

        it('Dialog("content")', function () {
            var app = new Dialog('内容');
            expect($('.zui-dialog-wrap').length).toBe(1);
            app.ele.find('.zui-dialog-btns').triggerHandler('click');
        });

        it('Dialog({content:"content"})', function () {
            var app = new Dialog({content: '内容'});
            expect($('.zui-dialog-wrap').length).toBe(1);
            app.ele.find('.zui-dialog-btns').triggerHandler('click');
        });

        it('Vertical buttons', function (){
            new Dialog({content:'内容', horizontal:false});
            expect($('.zui-dialog-btngroup-v').length).toBe(1);
        });

        it('Vertical buttons', function (){
            new Dialog({content:'内容', horizontal:false});
            expect($('.zui-dialog-btngroup-v').length).toBe(1);
            expect($('.zui-dialog-btngroup-h').length).toBe(0);
        });

        it('Horizontal buttons', function (){
            new Dialog({content:'内容', horizontal:true});
            expect($('.zui-dialog-btngroup-v').length).toBe(0);
            expect($('.zui-dialog-btngroup-h').length).toBe(1);
        });

        it('Default horizontal buttons', function (){
            new Dialog({content:'内容'});
            expect($('.zui-dialog-btngroup-v').length).toBe(0);
            expect($('.zui-dialog-btngroup-h').length).toBe(1);
        });

        it('Default hidden', function (){
            new Dialog({content:'内容'});
            expect($('.zui-dialog-wrap-mask').css('display')).toEqual('none');
        });

        it('Dialog show style check', function (){
            var app = new Dialog({content:'内容'});
            app.show();
            expect($('.zui-dialog-wrap-mask').css('display')).toEqual('block');
        });

        it('Button click action', function (){
            var app = new Dialog({content:'内容'});
            app.show();
            app.ele.find('.zui-dialog-btns').first().trigger('click');

            setTimeout(function(){
                expect($('.zui-dialog-wrap-mask').length).toBe(0);
            }, 400);
        });

        it('Default for two buttons', function (){
            var app = new Dialog({content:'内容'});
            app.show();
            expect(app.ele.find('.zui-dialog-btns').length).toBe(1);
        });

        it('Test title value', function (){
            var app = new Dialog({content:'内容', title:'test'});
            app.show();
            var text = app.ele.find('.zui-dialog-header').text();
            expect(text).toEqual('test');
        });

        it('Html content test', function (){
            var app = new Dialog({content:'<span class="zui-dialog-test"></span>', title:'test'});
            app.show();
            expect(app.ele.find('.zui-dialog-test').length).toBe(1);
        });

        it('Custom button', function (){
            var app = new Dialog({content:'内容', buttons:[
                {text:'按钮1',callback:function(){}},
                {text:'按钮2',callback:function(){}},
                {text:'按钮3',callback:function(){}}
            ]});
            app.show();
            expect(app.ele.find('.zui-dialog-btns').length).toBe(3);
        });

        it('Event: show', function (){
            var app = new Dialog({content:'内容'});
            var value = 0;
            app.show();
            app.on('show', function(){
                value = 1;
            });
            setTimeout(function(){
                expect(value).toEqual('1');
            },400);

        });

        it('Event: hide', function (){
            var app = new Dialog({content:'内容'});
            var value = 0;
            app.show();
            app.hide();
            app.on('hide', function(){
                value = 1;
            });
            setTimeout(function(){
                expect(value).toEqual('1');
            },400);

        });

        it('Event: destroy', function (){
            var app = new Dialog({content:'内容'});
            var value = 0;
            app.destroy();
            app.on('destroy', function(){
                value = 1;
            });
            setTimeout(function(){
                expect(value).toEqual('1');
            },400);

        });

    });
});

@@ -173,32 +173,33 @@
 , function () %7B%0A
+%0A
         afterEac
@@ -2043,337 +2043,8 @@
 );%0A%0A
-        it('Button click action', function ()%7B%0A            var app = new Dialog(%7Bcontent:'%E5%86%85%E5%AE%B9'%7D);%0A            app.show();%0A            app.ele.find('.zui-dialog-btns').first().trigger('click');%0A%0A            setTimeout(function()%7B%0A                expect($('.zui-dialog-wrap-mask').length).toBe(0);%0A            %7D, 400);%0A        %7D);%0A%0A
     
@@ -3142,19 +3142,28 @@
 it('
-Event: show
+Animation time %3C 200
 ', f
@@ -3240,126 +3240,17 @@
     
-var value = 0;%0A            app.show();%0A            app.on('show', function()%7B%0A                value = 1;%0A            %7D
+app.show(
 );%0A 
@@ -3306,34 +3306,57 @@
  expect(
-value).toEqual('1'
+$('.zui-dialog-wrap-mask').length).toBe(1
 );%0A     
@@ -3356,39 +3356,38 @@
 ;%0A            %7D,
-4
+1
 00);%0A
-%0A
         %7D);%0A%0A   
@@ -3399,18 +3399,14 @@
 it('
-Event: hid
+AniTim
 e', 
@@ -3468,37 +3468,25 @@
 '%E5%86%85%E5%AE%B9'
-%7D);%0A            var value = 0
+, aniTime: 1000%7D)
 ;%0A  
@@ -3523,522 +3523,95 @@
     
-app.hide();%0A            app.on('hide', function()%7B%0A                value = 1;%0A            %7D);%0A            setTimeout(function()%7B%0A                expect(value).toEqual('1');%0A            %7D,400);%0A%0A        %7D);%0A%0A        it('Event: destroy', function ()%7B%0A            var app = new Dialog(%7Bcontent:'%E5%86%85%E5%AE%B9'%7D);%0A            var value = 0;%0A            app.destroy();%0A            app.on('destroy', function()%7B%0A                value = 1;%0A            %7D);%0A            setTimeout(function()%7B%0A                expect(value).toEqual('1'
+setTimeout(function()%7B%0A                expect($('.zui-dialog-wrap-mask').length).toBe(1
 );%0A 
@@ -3627,15 +3627,14 @@
   %7D,
-4
+5
 00);%0A
-%0A
     

update dialog test case