Commit 8586891a authored by 杨奕's avatar 杨奕 Committed by GitHub

use chrome to run tests (#7521)

* use chrome to run tests

* fix karma config lint

* remove phantomjs
parent 7ceecce5
...@@ -2,6 +2,9 @@ sudo: false ...@@ -2,6 +2,9 @@ sudo: false
language: node_js language: node_js
node_js: stable node_js: stable
before_install: before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- export TRAVIS_COMMIT_MSG="[deploy] $(git log --format='%h - %B' --no-merges -n 1)" - export TRAVIS_COMMIT_MSG="[deploy] $(git log --format='%h - %B' --no-merges -n 1)"
- export TRAVIS_COMMIT_USER="$(git log --no-merges -n 1 --format=%an)" - export TRAVIS_COMMIT_USER="$(git log --no-merges -n 1 --format=%an)"
- export TRAVIS_COMMIT_EMAIL="$(git log --no-merges -n 1 --format=%ae)" - export TRAVIS_COMMIT_EMAIL="$(git log --no-merges -n 1 --format=%ae)"
......
var fs = require('fs'); var fs = require('fs');
var path = require('path'); var path = require('path');
var version = process.env.VERSION || require('../../package.json').version; var version = process.env.VERSION || require('../../package.json').version;
var content = { '1.0.9': '1.0', '1.1.6': '1.1', '1.2.9': '1.2', '1.3.7': '1.3', '1.4.6': '1.4' }; var content = { '1.0.9': '1.0', '1.1.6': '1.1', '1.2.9': '1.2', '1.3.7': '1.3', '1.4.7': '1.4' };
if (!content[version]) content[version] = '2.0'; if (!content[version]) content[version] = '2.0';
fs.writeFileSync(path.resolve(__dirname, '../../examples/versions.json'), JSON.stringify(content)); fs.writeFileSync(path.resolve(__dirname, '../../examples/versions.json'), JSON.stringify(content));
{"1.0.9":"1.0","1.1.6":"1.1","1.2.9":"1.2","1.3.7":"1.3","1.4.7":"1.4","2.0.0-alpha.3":"2.0"} {"1.0.9":"1.0","1.1.6":"1.1","1.2.9":"1.2","1.3.7":"1.3","1.4.6":"1.4","2.0.0-alpha.3":"2.0"}
\ No newline at end of file \ No newline at end of file
...@@ -4,12 +4,18 @@ var webpackConfig = require('../../build/cooking.test'); ...@@ -4,12 +4,18 @@ var webpackConfig = require('../../build/cooking.test');
// delete webpackConfig.entry; // delete webpackConfig.entry;
module.exports = function(config) { module.exports = function(config) {
config.set({ var configuration = {
// to run in additional browsers: // to run in additional browsers:
// 1. install corresponding karma launcher // 1. install corresponding karma launcher
// http://karma-runner.github.io/0.13/config/browsers.html // http://karma-runner.github.io/0.13/config/browsers.html
// 2. add it to the `browsers` array below. // 2. add it to the `browsers` array below.
browsers: ['PhantomJS'], browsers: ['Chrome'],
customLaunchers: {
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
frameworks: ['mocha', 'sinon-chai'], frameworks: ['mocha', 'sinon-chai'],
reporters: ['spec', 'coverage'], reporters: ['spec', 'coverage'],
files: ['./index.js'], files: ['./index.js'],
...@@ -32,5 +38,11 @@ module.exports = function(config) { ...@@ -32,5 +38,11 @@ module.exports = function(config) {
timeout: 4000 timeout: 4000
} }
} }
}); };
if (process.env.TRAVIS) {
configuration.browsers = ['Chrome_travis_ci'];
}
config.set(configuration);
}; };
...@@ -85,26 +85,22 @@ describe('Upload', () => { ...@@ -85,26 +85,22 @@ describe('Upload', () => {
props: { props: {
action: '/upload', action: '/upload',
onSuccess(res, file, fileList) { onSuccess(res, file, fileList) {
console.log('onSuccess', res);
if (handlers.onSuccess) { if (handlers.onSuccess) {
handlers.onSuccess(res, file, fileList); handlers.onSuccess(res, file, fileList);
} }
}, },
onError(err, file, fileList) { onError(err, file, fileList) {
console.log('onError', err, file, fileList);
if (handlers.onError) { if (handlers.onError) {
handlers.onError(err, file, fileList); handlers.onError(err, file, fileList);
} }
}, },
onPreview(file) { onPreview(file) {
console.log('onPreview', file);
if (handlers.onPreview) { if (handlers.onPreview) {
handlers.onPreview(file); handlers.onPreview(file);
} }
}, },
limit: 2, limit: 2,
onExceed(files, fileList) { onExceed(files, fileList) {
console.log('onExceed', files, fileList);
if (handlers.onExceed) { if (handlers.onExceed) {
handlers.onExceed(files, fileList); handlers.onExceed(files, fileList);
} }
...@@ -130,10 +126,11 @@ describe('Upload', () => { ...@@ -130,10 +126,11 @@ describe('Upload', () => {
}); });
it('upload success', done => { it('upload success', done => {
const files = [{ const file = new Blob([JSON.stringify({}, null, 2)], {
name: 'success.png', type: 'application/json'
type: 'xml' });
}]; file.name = 'success.png';
const files = [file];
handlers.onSuccess = (res, file, fileList) => { handlers.onSuccess = (res, file, fileList) => {
expect(file.name).to.equal('success.png'); expect(file.name).to.equal('success.png');
...@@ -150,10 +147,11 @@ describe('Upload', () => { ...@@ -150,10 +147,11 @@ describe('Upload', () => {
}); });
it('upload fail', done => { it('upload fail', done => {
const files = [{ const file = new Blob([JSON.stringify({}, null, 2)], {
name: 'fail.png', type: 'application/json'
type: 'xml' });
}]; file.name = 'fail.png';
const files = [file];
handlers.onError = (err, file, fileList) => { handlers.onError = (err, file, fileList) => {
expect(err instanceof Error).to.equal(true); expect(err instanceof Error).to.equal(true);
...@@ -168,10 +166,11 @@ describe('Upload', () => { ...@@ -168,10 +166,11 @@ describe('Upload', () => {
}, 100); }, 100);
}); });
it('preview file', done => { it('preview file', done => {
const files = [{ const file = new Blob([JSON.stringify({}, null, 2)], {
name: 'success.png', type: 'application/json'
type: 'xml' });
}]; file.name = 'success.png';
const files = [file];
handlers.onPreview = (file) => { handlers.onPreview = (file) => {
expect(file.response).to.equal('success.png'); expect(file.response).to.equal('success.png');
...@@ -191,10 +190,11 @@ describe('Upload', () => { ...@@ -191,10 +190,11 @@ describe('Upload', () => {
}, 100); }, 100);
}); });
it('file remove', done => { it('file remove', done => {
const files = [{ const file = new Blob([JSON.stringify({}, null, 2)], {
name: 'success.png', type: 'application/json'
type: 'xml' });
}]; file.name = 'success.png';
const files = [file];
handlers.onSuccess = (res, file, fileList) => { handlers.onSuccess = (res, file, fileList) => {
uploader.$el.querySelector('.el-upload-list .el-icon-close').click(); uploader.$el.querySelector('.el-upload-list .el-icon-close').click();
...@@ -211,10 +211,11 @@ describe('Upload', () => { ...@@ -211,10 +211,11 @@ describe('Upload', () => {
}, 100); }, 100);
}); });
it('clear files', done => { it('clear files', done => {
const files = [{ const file = new Blob([JSON.stringify({}, null, 2)], {
name: 'success.png', type: 'application/json'
type: 'xml' });
}]; file.name = 'success.png';
const files = [file];
handlers.onSuccess = (res, file, fileList) => { handlers.onSuccess = (res, file, fileList) => {
uploader.clearFiles(); uploader.clearFiles();
...@@ -252,8 +253,6 @@ describe('Upload', () => { ...@@ -252,8 +253,6 @@ describe('Upload', () => {
}); });
}; };
console.log(uploader.$refs['upload-inner'].limit, uploader.$refs['upload-inner'].fileList, uploader.$refs['upload-inner'].onExceed);
uploader.$nextTick(_ => uploader.$refs['upload-inner'].handleChange({ target: { files }})); uploader.$nextTick(_ => uploader.$refs['upload-inner'].handleChange({ target: { files }}));
}); });
}); });
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment