Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 1cb6117f
authored
Oct 16, 2017
by
cbauerme
Committed by
Sushant
Oct 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test(unit): do not use sinon syntactic sugar returns (#8491)
1 parent
16864699
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
test/unit/instance-validator.test.js
test/unit/model/find-create-find.test.js
test/unit/instance-validator.test.js
View file @
1cb6117
...
...
@@ -87,7 +87,9 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
it
(
'should run beforeValidate hook but not afterValidate hook when _validate is unsuccessful'
,
()
=>
{
const
failingInstanceValidator
=
new
InstanceValidator
(
this
.
User
.
build
());
sinon
.
stub
(
failingInstanceValidator
,
'_validate'
).
returns
(
Promise
.
reject
());
sinon
.
stub
(
failingInstanceValidator
,
'_validate'
,
()
=>
{
return
Promise
.
reject
();
});
const
beforeValidate
=
sinon
.
spy
();
const
afterValidate
=
sinon
.
spy
();
this
.
User
.
beforeValidate
(
beforeValidate
);
...
...
@@ -110,7 +112,9 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
describe
(
'validatedFailed hook'
,
()
=>
{
it
(
'should call validationFailed hook when validation fails'
,
()
=>
{
const
failingInstanceValidator
=
new
InstanceValidator
(
this
.
User
.
build
());
sinon
.
stub
(
failingInstanceValidator
,
'_validate'
).
returns
(
Promise
.
reject
());
sinon
.
stub
(
failingInstanceValidator
,
'_validate'
,
()
=>
{
return
Promise
.
reject
();
});
const
validationFailedHook
=
sinon
.
spy
();
this
.
User
.
validationFailed
(
validationFailedHook
);
...
...
@@ -121,7 +125,9 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
it
(
'should not replace the validation error in validationFailed hook by default'
,
()
=>
{
const
failingInstanceValidator
=
new
InstanceValidator
(
this
.
User
.
build
());
sinon
.
stub
(
failingInstanceValidator
,
'_validate'
).
returns
(
Promise
.
reject
(
new
SequelizeValidationError
()));
sinon
.
stub
(
failingInstanceValidator
,
'_validate'
,
()
=>
{
return
Promise
.
reject
(
new
SequelizeValidationError
());
});
const
validationFailedHook
=
sinon
.
stub
().
returns
(
Promise
.
resolve
());
this
.
User
.
validationFailed
(
validationFailedHook
);
...
...
@@ -132,7 +138,9 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
it
(
'should replace the validation error if validationFailed hook creates a new error'
,
()
=>
{
const
failingInstanceValidator
=
new
InstanceValidator
(
this
.
User
.
build
());
sinon
.
stub
(
failingInstanceValidator
,
'_validate'
).
returns
(
Promise
.
reject
(
new
SequelizeValidationError
()));
sinon
.
stub
(
failingInstanceValidator
,
'_validate'
,
()
=>
{
return
Promise
.
reject
(
new
SequelizeValidationError
());
});
const
validationFailedHook
=
sinon
.
stub
().
throws
(
new
Error
(
'validation failed hook error'
));
this
.
User
.
validationFailed
(
validationFailedHook
);
...
...
test/unit/model/find-create-find.test.js
View file @
1cb6117
...
...
@@ -52,7 +52,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
where
=
{
prop
:
Math
.
random
().
toString
()},
findSpy
=
this
.
sinon
.
stub
(
Model
,
'findOne'
);
this
.
sinon
.
stub
(
Model
,
'create'
).
returns
(
Promise
.
reject
(
new
UniqueConstraintError
()));
this
.
sinon
.
stub
(
Model
,
'create'
,
()
=>
{
return
Promise
.
reject
(
new
UniqueConstraintError
());
});
findSpy
.
onFirstCall
().
returns
(
Promise
.
resolve
(
null
));
findSpy
.
onSecondCall
().
returns
(
Promise
.
resolve
(
result
));
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment