Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
98850a18
Commit
98850a18
authored
Feb 15, 2017
by
baiyaaaaa
Committed by
杨奕
Feb 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix test
parent
bd008bae
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
15 deletions
+16
-15
packages/upload/src/ajax.js
packages/upload/src/ajax.js
+8
-5
test/unit/specs/upload.spec.js
test/unit/specs/upload.spec.js
+8
-10
No files found.
packages/upload/src/ajax.js
View file @
98850a18
function
getError
(
action
,
option
,
xhr
)
{
const
msg
=
xhr
.
response
?
(
xhr
.
response
.
error
||
xhr
.
response
)
:
xhr
.
responseText
?
xhr
.
responseText
:
`fail to post
${
action
}
${
xhr
.
status
}
'`
;
let
msg
;
if
(
xhr
.
response
)
{
msg
=
`
${
xhr
.
status
}
${
xhr
.
response
.
error
||
xhr
.
response
}
`
;
}
else
if
(
xhr
.
responseText
)
{
msg
=
`
${
xhr
.
status
}
${
xhr
.
responseText
}
`
;
}
else
{
msg
=
`fail to post
${
action
}
${
xhr
.
status
}
'`
;
}
const
err
=
new
Error
(
msg
);
err
.
status
=
xhr
.
status
;
...
...
test/unit/specs/upload.spec.js
View file @
98850a18
...
...
@@ -41,7 +41,7 @@ describe('ajax', () => {
});
it
(
'
40x code should be error
'
,
done
=>
{
option
.
onError
=
e
=>
{
expect
(
e
.
toString
()).
to
.
contain
(
'
404
'
);
expect
(
e
.
toString
()).
to
.
contain
(
'
404
Not found
'
);
done
();
};
...
...
@@ -90,10 +90,10 @@ describe('Upload', () => {
handlers
.
onSuccess
(
res
,
file
,
fileList
);
}
},
onError
(
err
,
response
,
file
)
{
console
.
log
(
'
onError
'
,
err
,
response
);
onError
(
err
,
file
,
fileList
)
{
console
.
log
(
'
onError
'
,
err
,
file
,
fileList
);
if
(
handlers
.
onError
)
{
handlers
.
onError
(
err
,
response
,
file
);
handlers
.
onError
(
err
,
file
,
fileList
);
}
},
onPreview
(
file
)
{
...
...
@@ -148,9 +148,9 @@ describe('Upload', () => {
type
:
'
xml
'
}];
handlers
.
onError
=
(
err
,
response
,
file
)
=>
{
handlers
.
onError
=
(
err
,
file
,
fileList
)
=>
{
expect
(
err
instanceof
Error
).
to
.
equal
(
true
);
expect
(
response
).
to
.
equal
(
'
error 400
'
);
expect
(
file
.
name
).
to
.
equal
(
'
fail.png
'
);
done
();
};
...
...
@@ -173,7 +173,7 @@ describe('Upload', () => {
handlers
.
onSuccess
=
(
res
,
file
,
fileList
)
=>
{
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
)
=>
{
uploader
.
$el
.
querySelector
(
'
.el-upload
__files .el-upload__btn-delet
e
'
).
click
();
uploader
.
$el
.
querySelector
(
'
.el-upload
-list .el-icon-clos
e
'
).
click
();
uploader
.
$nextTick
(
_
=>
{
expect
(
uploader
.
fileList
.
length
).
to
.
equal
(
0
);
expect
(
uploader
.
$el
.
querySelector
(
'
.el-upload__files
'
)).
to
.
not
.
exist
;
done
();
});
};
...
...
@@ -214,7 +213,6 @@ describe('Upload', () => {
uploader
.
clearFiles
();
uploader
.
$nextTick
(
_
=>
{
expect
(
uploader
.
fileList
.
length
).
to
.
equal
(
0
);
expect
(
uploader
.
$el
.
querySelector
(
'
.el-upload__files
'
)).
to
.
not
.
exist
;
done
();
});
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment