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 3e3e208a
authored
Aug 20, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix jshint
1 parent
615b74a4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
test/unit/model/find-create-find.test.js
test/unit/model/find-create-find.test.js
View file @
3e3e208
...
...
@@ -6,7 +6,6 @@ var chai = require('chai')
,
Support
=
require
(
__dirname
+
'/../support'
)
,
UniqueConstraintError
=
require
(
__dirname
+
'/../../../lib/errors'
).
UniqueConstraintError
,
current
=
Support
.
sequelize
,
cls
=
require
(
'continuation-local-storage'
)
,
sinon
=
require
(
'sinon'
)
,
Promise
=
require
(
'bluebird'
);
...
...
@@ -38,9 +37,10 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it
(
'should create if first find call is empty'
,
function
()
{
var
result
=
{}
,
where
=
{
prop
:
Math
.
random
().
toString
()}
,
findSpy
=
this
.
sinon
.
stub
(
Model
,
'findOne'
).
returns
(
Promise
.
resolve
(
null
))
,
createSpy
=
this
.
sinon
.
stub
(
Model
,
'create'
).
returns
(
Promise
.
resolve
(
result
));
this
.
sinon
.
stub
(
Model
,
'findOne'
).
returns
(
Promise
.
resolve
(
null
));
return
expect
(
Model
.
findCreateFind
({
where
:
where
})).
to
.
eventually
.
eql
([
result
,
true
]).
then
(
function
()
{
...
...
@@ -51,8 +51,9 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it
(
'should do a second find if create failed do to unique constraint'
,
function
()
{
var
result
=
{}
,
where
=
{
prop
:
Math
.
random
().
toString
()}
,
findSpy
=
this
.
sinon
.
stub
(
Model
,
'findOne'
)
,
createSpy
=
this
.
sinon
.
stub
(
Model
,
'create'
).
returns
(
Promise
.
reject
(
new
UniqueConstraintError
()));
,
findSpy
=
this
.
sinon
.
stub
(
Model
,
'findOne'
);
this
.
sinon
.
stub
(
Model
,
'create'
).
returns
(
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