fix: preview unit test

This commit is contained in:
niunai 2017-05-24 16:53:15 +08:00
parent 38d8003532
commit 19b814f1db
2 changed files with 13 additions and 3 deletions

View File

@ -9,7 +9,7 @@ var travis = process.env.TRAVIS;
module.exports = function(config) { module.exports = function(config) {
config.set({ config.set({
browsers: travis ? ['PhantomJS'] : ['Chrome'], browsers: travis ? ['PhantomJS'] : ['PhantomJS', 'Chrome'],
frameworks: ['mocha', 'sinon-chai'], frameworks: ['mocha', 'sinon-chai'],
reporters: ['spec', 'coverage'], reporters: ['spec', 'coverage'],
files: ['./index.js'], files: ['./index.js'],

View File

@ -1,4 +1,5 @@
import ImagePreview from 'packages/image-preview'; import ImagePreview from 'packages/image-preview';
import Wrapper from 'avoriaz/dist/Wrapper';
describe('ImagePreview', () => { describe('ImagePreview', () => {
beforeEach(() => { beforeEach(() => {
@ -22,7 +23,11 @@ describe('ImagePreview', () => {
expect(document.querySelector('.van-image-preview')).to.exist; expect(document.querySelector('.van-image-preview')).to.exist;
setTimeout(() => { setTimeout(() => {
document.querySelector('.van-swipe-item').click(); const image = document.querySelector('.van-image-preview');
const avImage = new Wrapper({ elm: image }, () => {}, false);
avImage.simulate('click');
avImage.simulate('touchstart');
avImage.simulate('touchend');
setTimeout(() => { setTimeout(() => {
expect(document.querySelector('.van-image-preview').__vue__.$parent.value).to.be.false; expect(document.querySelector('.van-image-preview').__vue__.$parent.value).to.be.false;
expect(document.body.style.overflow).to.equal(''); expect(document.body.style.overflow).to.equal('');
@ -42,7 +47,12 @@ describe('ImagePreview', () => {
expect(document.querySelector('.van-image-preview')).to.exist; expect(document.querySelector('.van-image-preview')).to.exist;
setTimeout(() => { setTimeout(() => {
document.querySelector('.van-swipe-item').click(); const image = document.querySelector('.van-image-preview');
const avImage = new Wrapper({ elm: image }, () => {}, false);
avImage.simulate('click');
avImage.simulate('touchstart');
avImage.simulate('touchend');
setTimeout(() => { setTimeout(() => {
expect(document.querySelector('.van-image-preview').__vue__.$parent.value).to.be.false; expect(document.querySelector('.van-image-preview').__vue__.$parent.value).to.be.false;
expect(document.body.style.overflow).to.equal('hidden'); expect(document.body.style.overflow).to.equal('hidden');