mirror of https://github.com/ElemeFE/element
fix test
parent
bd008bae68
commit
98850a1832
|
@ -1,9 +1,12 @@
|
||||||
function getError(action, option, xhr) {
|
function getError(action, option, xhr) {
|
||||||
const msg = xhr.response
|
let msg;
|
||||||
? (xhr.response.error || xhr.response)
|
if (xhr.response) {
|
||||||
: xhr.responseText
|
msg = `${xhr.status} ${xhr.response.error || xhr.response}`;
|
||||||
? xhr.responseText
|
} else if (xhr.responseText) {
|
||||||
: `fail to post ${action} ${xhr.status}'`;
|
msg = `${xhr.status} ${xhr.responseText}`;
|
||||||
|
} else {
|
||||||
|
msg = `fail to post ${action} ${xhr.status}'`;
|
||||||
|
}
|
||||||
|
|
||||||
const err = new Error(msg);
|
const err = new Error(msg);
|
||||||
err.status = xhr.status;
|
err.status = xhr.status;
|
||||||
|
|
|
@ -41,7 +41,7 @@ describe('ajax', () => {
|
||||||
});
|
});
|
||||||
it('40x code should be error', done => {
|
it('40x code should be error', done => {
|
||||||
option.onError = e => {
|
option.onError = e => {
|
||||||
expect(e.toString()).to.contain('404');
|
expect(e.toString()).to.contain('404 Not found');
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -90,10 +90,10 @@ describe('Upload', () => {
|
||||||
handlers.onSuccess(res, file, fileList);
|
handlers.onSuccess(res, file, fileList);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError(err, response, file) {
|
onError(err, file, fileList) {
|
||||||
console.log('onError', err, response);
|
console.log('onError', err, file, fileList);
|
||||||
if (handlers.onError) {
|
if (handlers.onError) {
|
||||||
handlers.onError(err, response, file);
|
handlers.onError(err, file, fileList);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPreview(file) {
|
onPreview(file) {
|
||||||
|
@ -148,9 +148,9 @@ describe('Upload', () => {
|
||||||
type: 'xml'
|
type: 'xml'
|
||||||
}];
|
}];
|
||||||
|
|
||||||
handlers.onError = (err, response, file) => {
|
handlers.onError = (err, file, fileList) => {
|
||||||
expect(err instanceof Error).to.equal(true);
|
expect(err instanceof Error).to.equal(true);
|
||||||
expect(response).to.equal('error 400');
|
expect(file.name).to.equal('fail.png');
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ describe('Upload', () => {
|
||||||
|
|
||||||
handlers.onSuccess = (res, file, fileList) => {
|
handlers.onSuccess = (res, file, fileList) => {
|
||||||
uploader.$nextTick(_ => {
|
uploader.$nextTick(_ => {
|
||||||
uploader.$el.querySelector('.el-upload__files .is-finished a').click();
|
uploader.$el.querySelector('.el-upload-list .is-success a').click();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -190,10 +190,9 @@ describe('Upload', () => {
|
||||||
}];
|
}];
|
||||||
|
|
||||||
handlers.onSuccess = (res, file, fileList) => {
|
handlers.onSuccess = (res, file, fileList) => {
|
||||||
uploader.$el.querySelector('.el-upload__files .el-upload__btn-delete').click();
|
uploader.$el.querySelector('.el-upload-list .el-icon-close').click();
|
||||||
uploader.$nextTick(_ => {
|
uploader.$nextTick(_ => {
|
||||||
expect(uploader.fileList.length).to.equal(0);
|
expect(uploader.fileList.length).to.equal(0);
|
||||||
expect(uploader.$el.querySelector('.el-upload__files')).to.not.exist;
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -214,7 +213,6 @@ describe('Upload', () => {
|
||||||
uploader.clearFiles();
|
uploader.clearFiles();
|
||||||
uploader.$nextTick(_ => {
|
uploader.$nextTick(_ => {
|
||||||
expect(uploader.fileList.length).to.equal(0);
|
expect(uploader.fileList.length).to.equal(0);
|
||||||
expect(uploader.$el.querySelector('.el-upload__files')).to.not.exist;
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue