test: update upload test

pull/1534/head
tanjinzhou 2019-12-10 13:16:16 +08:00
parent 843d9dc82f
commit cdc0e1a5f6
3 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1,14 @@
import mock from 'xhr-mock';
export function setup() {
mock.setup();
mock.post('http://upload.com/', (req, res) => {
req.headers({
'content-length': 100,
});
req.body('thisisbody');
return res;
});
}
export const teardown = mock.teardown.bind(mock);

View File

@ -3,10 +3,13 @@ import Upload from '..';
import { T, fileToObject, genPercentAdd, getFileItem, removeFileItem } from '../utils';
import PropsTypes from '../../_util/vue-types';
import { UploadListProps } from '../interface';
import { setup, teardown } from './mock';
UploadListProps.items = PropsTypes.any;
describe('Upload', () => {
beforeEach(() => setup());
afterEach(() => teardown());
it('should get refs inside Upload in componentDidMount', () => {
let ref = null;
const APP = {

View File

@ -176,7 +176,8 @@
"webpack-cli": "^3.2.1",
"webpack-dev-server": "^3.1.14",
"webpack-merge": "^4.1.1",
"webpackbar": "^3.1.5"
"webpackbar": "^3.1.5",
"xhr-mock": "^2.5.1"
},
"dependencies": {
"@ant-design/icons": "^2.1.1",