define(function (require) {
    'use strict';

    var util = require('util');
    var Img = require('components/mip-img');
    var img = new Img();
    var cEvent = util.event.create('click');

    describe('mip img', function () {
        it('firstInviewCallback', function () {
            var HTML = '<mip-img alt="mip img" popup layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg"></mip-img>';
            img.element = util.dom.create(HTML);
            img.element.customElement = {resourcesComplete: function () {}};
            img.firstInviewCallback();
            var ele = img.element.querySelectorAll('img');
            expect(ele.length).to.be.at.least(1);
        });

        it('img load error', function (done) {
            var HTML = '<mip-img src="https://www.example.com/xx.jpg"></mip-img>';
            img.element = util.dom.create(HTML);
            img.element.customElement = {resourcesComplete: function () {}};
            img.firstInviewCallback();
            var ele = img.element.querySelector('img');
            setTimeout(function () {
                expect(ele.src.indexOf('mip_img_ori')).to.be.at.least(0);
                done();
            }, 1000);
        });

        it('popupHandle', function (done) {
            var HTML = '<mip-img alt="mip img" popup layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg"></mip-img>';
            img.element = util.dom.create(HTML);
            img.element.customElement = {resourcesComplete: function () {}};
            img.firstInviewCallback();

            var ele = img.element.querySelector('img');
            img.popupHandle(cEvent, img.element, ele);
            setTimeout(function () {
                var ele = document.body.querySelectorAll('.mip-img-popUp-wrapper');
                expect(ele.length).to.be.at.least(1);
                done();
            }, 1000);
        });

        it('popup hash exist', function (done) {
            setTimeout(function () {
                var HTML = '<mip-img alt="mip img" popup layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg"></mip-img>';
                img.element = util.dom.create(HTML);
                img.element.customElement = {resourcesComplete: function () {}};
                img.firstInviewCallback();

                var ele = img.element.querySelector('img');
                var result = img.createPopup(ele);
                var wrapper = document.body.querySelector('.mip-img-popUp-wrapper');
                expect(result).to.be.equal(wrapper);
                done();
            }, 1000);
        });

        it('popupClickHandle', function (done) {
            var HTML = '<mip-img alt="mip img" popup layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg"></mip-img>';
            img.element = util.dom.create(HTML);
            img.element.customElement = {resourcesComplete: function () {}};
            img.firstInviewCallback();

            setTimeout(function () {
                var popup = document.querySelector('.mip-img-popUp-wrapper');
                var popUpBg = popup.querySelector('.mip-img-popUp-bg');
                var popupImg = popup.querySelector('img');
                var ele = img.element.querySelector('img');
                expect(popup).to.not.be.undefined;
                expect(popUpBg).to.not.be.undefined;
                expect(popupImg).to.not.be.undefined;
                expect(ele).to.not.be.undefined;
                img.popupClickHandle({
                    popup: popup,
                    popUpBg: popUpBg,
                    popupImg: popupImg,
                    img: ele
                });
                done();
            }, 1000);
        });
    });
});
@@ -1267,22 +1267,27 @@
 t('popup
-Handle
+ hash exist
 ', funct
@@ -1624,33 +1624,32 @@
 viewCallback();%0A
-%0A
             var 
@@ -1747,290 +1747,8 @@
 e);%0A
-            setTimeout(function () %7B%0A                var ele = document.body.querySelectorAll('.mip-img-popUp-wrapper');%0A                expect(ele.length).to.be.at.least(1);%0A                done();%0A            %7D, 1000);%0A        %7D);%0A%0A        it('popup hash exist', function (done) %7B
 %0A   

add unit test