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 94f5e189
authored
Apr 10, 2015
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add chai missing assertions to dev deps and change some assertions not.to.be.def…
…ined -> to.be.undefined
1 parent
fb94baeb
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
57 additions
and
55 deletions
package.json
test/integration/associations/belongs-to-many.test.js
test/integration/associations/belongs-to.test.js
test/integration/associations/has-many.test.js
test/integration/associations/has-one.test.js
test/integration/instance.validations.test.js
test/integration/model.test.js
test/integration/model/upsert.test.js
test/integration/sequelize.transaction.test.js
test/support.js
package.json
View file @
94f5e18
...
...
@@ -46,6 +46,7 @@
"chai"
:
"^2.1.2"
,
"chai-as-promised"
:
"^4.3.0"
,
"chai-datetime"
:
"~1.3.0"
,
"chai-missing-assertions"
:
"^1.0.0"
,
"chai-spies"
:
"~0.5.1"
,
"coffee-script"
:
"~1.7.1"
,
"commander"
:
"^2.6.0"
,
...
...
test/integration/associations/belongs-to-many.test.js
View file @
94f5e18
...
...
@@ -216,7 +216,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
}).
then
(
function
(
projects
)
{
expect
(
projects
).
to
.
have
.
length
(
1
);
var
project
=
projects
[
0
];
expect
(
project
.
ProjectUsers
).
to
.
be
.
defined
;
expect
(
project
.
ProjectUsers
).
to
.
be
.
ok
;
expect
(
project
.
status
).
not
.
to
.
exist
;
expect
(
project
.
ProjectUsers
.
status
).
to
.
equal
(
'active'
);
});
...
...
@@ -1086,7 +1086,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
);
}).
spread
(
function
(
user
,
projects
)
{
var
project
=
projects
[
0
];
expect
(
project
).
to
.
be
.
defined
;
expect
(
project
).
to
.
be
.
ok
;
return
project
.
destroy
().
return
(
user
);
}).
then
(
function
(
user
)
{
return
self
.
User
.
find
({
...
...
@@ -1097,7 +1097,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var
projects
=
user
.
Projects
,
project
=
projects
[
0
];
expect
(
project
).
to
.
be
.
defined
;
expect
(
project
).
to
.
be
.
ok
;
});
});
...
...
@@ -1117,7 +1117,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
}).
then
(
function
(
projects
)
{
var
project
=
projects
[
0
];
expect
(
project
).
to
.
be
.
defined
;
expect
(
project
).
to
.
be
.
ok
;
return
self
.
user
.
removeProject
(
project
).
on
(
'sql'
,
function
(
sql
)
{
}).
return
(
project
);
}).
then
(
function
(
project
)
{
...
...
@@ -1180,13 +1180,13 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
});
}).
then
(
function
(
groups
)
{
var
group
=
groups
[
0
];
expect
(
group
).
to
.
be
.
defined
;
expect
(
group
).
to
.
be
.
ok
;
var
user
=
group
.
Users
[
0
];
expect
(
user
).
to
.
be
.
defined
;
expect
(
user
).
to
.
be
.
ok
;
var
project
=
user
.
Projects
[
0
];
expect
(
project
).
to
.
be
.
defined
;
expect
(
project
).
to
.
be
.
ok
;
expect
(
project
.
name
).
to
.
equal
(
'Good Will Hunting'
);
});
});
...
...
@@ -1307,7 +1307,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
}).
then
(
function
(
projects
)
{
var
project
=
projects
[
0
];
expect
(
project
.
UserProjects
).
to
.
be
.
defined
;
expect
(
project
.
UserProjects
).
to
.
be
.
ok
;
expect
(
project
.
status
).
not
.
to
.
exist
;
expect
(
project
.
UserProjects
.
status
).
to
.
equal
(
'active'
);
expect
(
project
.
UserProjects
.
data
).
to
.
equal
(
42
);
...
...
@@ -1325,7 +1325,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
}).
then
(
function
(
projects
)
{
var
project
=
projects
[
0
];
expect
(
project
.
UserProjects
).
to
.
be
.
defined
;
expect
(
project
.
UserProjects
).
to
.
be
.
ok
;
expect
(
project
.
status
).
not
.
to
.
exist
;
expect
(
project
.
UserProjects
.
status
).
to
.
equal
(
'active'
);
expect
(
project
.
UserProjects
.
data
).
not
.
to
.
exist
;
...
...
@@ -1877,7 +1877,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var
UserProjects
=
User
.
belongsToMany
(
Project
,
{
foreignKey
:
{
name
:
'user_id'
,
defaultValue
:
42
}});
expect
(
UserProjects
.
through
.
model
.
rawAttributes
.
user_id
).
to
.
be
.
defined
;
expect
(
UserProjects
.
through
.
model
.
rawAttributes
.
user_id
).
to
.
be
.
ok
;
expect
(
UserProjects
.
through
.
model
.
rawAttributes
.
user_id
.
references
).
to
.
equal
(
User
.
getTableName
());
expect
(
UserProjects
.
through
.
model
.
rawAttributes
.
user_id
.
referencesKey
).
to
.
equal
(
'uid'
);
expect
(
UserProjects
.
through
.
model
.
rawAttributes
.
user_id
.
defaultValue
).
to
.
equal
(
42
);
...
...
test/integration/associations/belongs-to.test.js
View file @
94f5e18
...
...
@@ -639,7 +639,7 @@ describe(Support.getTestDialectTeaser('BelongsTo'), function() {
}
});
expect
(
Task
.
rawAttributes
.
uid
).
to
.
be
.
defined
;
expect
(
Task
.
rawAttributes
.
uid
).
to
.
be
.
ok
;
expect
(
Task
.
rawAttributes
.
uid
.
allowNull
).
to
.
be
.
false
;
expect
(
Task
.
rawAttributes
.
uid
.
references
).
to
.
equal
(
User
.
getTableName
());
expect
(
Task
.
rawAttributes
.
uid
.
referencesKey
).
to
.
equal
(
'id'
);
...
...
@@ -661,7 +661,7 @@ describe(Support.getTestDialectTeaser('BelongsTo'), function() {
Profile
.
belongsTo
(
User
,
{
foreignKey
:
Profile
.
rawAttributes
.
user_id
});
expect
(
Profile
.
rawAttributes
.
user_id
).
to
.
be
.
defined
;
expect
(
Profile
.
rawAttributes
.
user_id
).
to
.
be
.
ok
;
expect
(
Profile
.
rawAttributes
.
user_id
.
references
).
to
.
equal
(
User
.
getTableName
());
expect
(
Profile
.
rawAttributes
.
user_id
.
referencesKey
).
to
.
equal
(
'uid'
);
expect
(
Profile
.
rawAttributes
.
user_id
.
allowNull
).
to
.
be
.
false
;
...
...
@@ -678,7 +678,7 @@ describe(Support.getTestDialectTeaser('BelongsTo'), function() {
Task
.
belongsTo
(
Project
,
{
foreignKey
:
{
allowNull
:
true
}});
expect
(
Task
.
rawAttributes
.
projectId
).
to
.
be
.
defined
;
expect
(
Task
.
rawAttributes
.
projectId
).
to
.
be
.
ok
;
expect
(
Task
.
rawAttributes
.
projectId
.
defaultValue
).
to
.
equal
(
42
);
expect
(
Task
.
rawAttributes
.
projectId
.
allowNull
).
to
.
be
.
ok
;
});
...
...
test/integration/associations/has-many.test.js
View file @
94f5e18
...
...
@@ -945,7 +945,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
}).
then
(
function
(
projects
)
{
expect
(
projects
).
to
.
have
.
length
(
1
);
var
project
=
projects
[
0
];
expect
(
project
.
ProjectUsers
).
to
.
be
.
defined
;
expect
(
project
.
ProjectUsers
).
to
.
be
.
ok
;
expect
(
project
.
status
).
not
.
to
.
exist
;
expect
(
project
.
ProjectUsers
.
status
).
to
.
equal
(
'active'
);
});
...
...
@@ -1613,7 +1613,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
);
}).
spread
(
function
(
user
,
projects
)
{
var
project
=
projects
[
0
];
expect
(
project
).
to
.
be
.
defined
;
expect
(
project
).
to
.
be
.
ok
;
return
project
.
destroy
().
return
(
user
);
}).
then
(
function
(
user
)
{
return
self
.
User
.
find
({
...
...
@@ -1624,7 +1624,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
var
projects
=
user
.
Projects
,
project
=
projects
[
0
];
expect
(
project
).
to
.
be
.
defined
;
expect
(
project
).
to
.
be
.
ok
;
});
});
...
...
@@ -1644,7 +1644,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
}).
then
(
function
(
projects
)
{
var
project
=
projects
[
0
];
expect
(
project
).
to
.
be
.
defined
;
expect
(
project
).
to
.
be
.
ok
;
return
self
.
user
.
removeProject
(
project
).
return
(
project
);
}).
then
(
function
(
project
)
{
return
self
.
user
.
setProjects
([
project
]);
...
...
@@ -1664,7 +1664,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
return
user
.
getPuppies
().
then
(
function
(
puppies
)
{
var
puppy
=
puppies
[
0
];
expect
(
puppy
).
to
.
be
.
defined
;
expect
(
puppy
).
to
.
be
.
ok
;
expect
(
puppy
.
rawAttributes
.
userId
).
to
.
be
.
ok
;
expect
(
puppy
.
userId
).
to
.
equal
(
user
.
id
);
});
...
...
@@ -1718,13 +1718,13 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
});
}).
then
(
function
(
groups
)
{
var
group
=
groups
[
0
];
expect
(
group
).
to
.
be
.
defined
;
expect
(
group
).
to
.
be
.
ok
;
var
user
=
group
.
Users
[
0
];
expect
(
user
).
to
.
be
.
defined
;
expect
(
user
).
to
.
be
.
ok
;
var
project
=
user
.
Projects
[
0
];
expect
(
project
).
to
.
be
.
defined
;
expect
(
project
).
to
.
be
.
ok
;
expect
(
project
.
name
).
to
.
equal
(
'Good Will Hunting'
);
});
});
...
...
@@ -1845,7 +1845,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
}).
then
(
function
(
projects
)
{
var
project
=
projects
[
0
];
expect
(
project
.
UserProjects
).
to
.
be
.
defined
;
expect
(
project
.
UserProjects
).
to
.
be
.
ok
;
expect
(
project
.
status
).
not
.
to
.
exist
;
expect
(
project
.
UserProjects
.
status
).
to
.
equal
(
'active'
);
expect
(
project
.
UserProjects
.
data
).
to
.
equal
(
42
);
...
...
@@ -1863,7 +1863,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
}).
then
(
function
(
projects
)
{
var
project
=
projects
[
0
];
expect
(
project
.
UserProjects
).
to
.
be
.
defined
;
expect
(
project
.
UserProjects
).
to
.
be
.
ok
;
expect
(
project
.
status
).
not
.
to
.
exist
;
expect
(
project
.
UserProjects
.
status
).
to
.
equal
(
'active'
);
expect
(
project
.
UserProjects
.
data
).
not
.
to
.
exist
;
...
...
@@ -2621,7 +2621,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
}
});
expect
(
Task
.
rawAttributes
.
uid
).
to
.
be
.
defined
;
expect
(
Task
.
rawAttributes
.
uid
).
to
.
be
.
ok
;
expect
(
Task
.
rawAttributes
.
uid
.
allowNull
).
to
.
be
.
false
;
expect
(
Task
.
rawAttributes
.
uid
.
references
).
to
.
equal
(
User
.
getTableName
());
expect
(
Task
.
rawAttributes
.
uid
.
referencesKey
).
to
.
equal
(
'id'
);
...
...
@@ -2632,14 +2632,14 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
}
});
expect
(
Task
.
rawAttributes
.
uid
).
not
.
to
.
be
.
defined
;
expect
(
Task
.
rawAttributes
.
uid
).
to
.
be
.
un
defined
;
expect
(
Task
.
associations
.
tasksusers
.
through
.
model
.
rawAttributes
.
taskId
).
to
.
be
.
defined
;
expect
(
Task
.
associations
.
tasksusers
.
through
.
model
.
rawAttributes
.
taskId
).
to
.
be
.
ok
;
expect
(
Task
.
associations
.
tasksusers
.
through
.
model
.
rawAttributes
.
taskId
.
allowNull
).
to
.
be
.
false
;
expect
(
Task
.
associations
.
tasksusers
.
through
.
model
.
rawAttributes
.
taskId
.
references
).
to
.
equal
(
Task
.
getTableName
());
expect
(
Task
.
associations
.
tasksusers
.
through
.
model
.
rawAttributes
.
taskId
.
referencesKey
).
to
.
equal
(
'id'
);
expect
(
Task
.
associations
.
tasksusers
.
through
.
model
.
rawAttributes
.
uid
).
to
.
be
.
defined
;
expect
(
Task
.
associations
.
tasksusers
.
through
.
model
.
rawAttributes
.
uid
).
to
.
be
.
ok
;
expect
(
Task
.
associations
.
tasksusers
.
through
.
model
.
rawAttributes
.
uid
.
allowNull
).
to
.
be
.
false
;
expect
(
Task
.
associations
.
tasksusers
.
through
.
model
.
rawAttributes
.
uid
.
references
).
to
.
equal
(
User
.
getTableName
());
expect
(
Task
.
associations
.
tasksusers
.
through
.
model
.
rawAttributes
.
uid
.
referencesKey
).
to
.
equal
(
'id'
);
...
...
@@ -2661,7 +2661,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
User
.
hasMany
(
Project
,
{
foreignKey
:
Project
.
rawAttributes
.
user_id
});
expect
(
Project
.
rawAttributes
.
user_id
).
to
.
be
.
defined
;
expect
(
Project
.
rawAttributes
.
user_id
).
to
.
be
.
ok
;
expect
(
Project
.
rawAttributes
.
user_id
.
references
).
to
.
equal
(
User
.
getTableName
());
expect
(
Project
.
rawAttributes
.
user_id
.
referencesKey
).
to
.
equal
(
'uid'
);
expect
(
Project
.
rawAttributes
.
user_id
.
defaultValue
).
to
.
equal
(
42
);
...
...
@@ -2678,7 +2678,7 @@ describe(Support.getTestDialectTeaser('HasMany'), function() {
User
.
hasMany
(
Task
,
{
foreignKey
:
{
allowNull
:
true
}});
expect
(
Task
.
rawAttributes
.
userId
).
to
.
be
.
defined
;
expect
(
Task
.
rawAttributes
.
userId
).
to
.
be
.
ok
;
expect
(
Task
.
rawAttributes
.
userId
.
defaultValue
).
to
.
equal
(
42
);
expect
(
Task
.
rawAttributes
.
userId
.
allowNull
).
to
.
be
.
ok
;
});
...
...
test/integration/associations/has-one.test.js
View file @
94f5e18
...
...
@@ -534,7 +534,7 @@ describe(Support.getTestDialectTeaser('HasOne'), function() {
}
});
expect
(
Profile
.
rawAttributes
.
uid
).
to
.
be
.
defined
;
expect
(
Profile
.
rawAttributes
.
uid
).
to
.
be
.
ok
;
expect
(
Profile
.
rawAttributes
.
uid
.
references
).
to
.
equal
(
User
.
getTableName
());
expect
(
Profile
.
rawAttributes
.
uid
.
referencesKey
).
to
.
equal
(
'id'
);
expect
(
Profile
.
rawAttributes
.
uid
.
allowNull
).
to
.
be
.
false
;
...
...
@@ -548,7 +548,7 @@ describe(Support.getTestDialectTeaser('HasOne'), function() {
}
});
expect
(
Profile
.
rawAttributes
.
uid
).
to
.
be
.
defined
;
expect
(
Profile
.
rawAttributes
.
uid
).
to
.
be
.
ok
;
expect
(
Profile
.
rawAttributes
.
uid
.
references
).
to
.
equal
(
User
.
getTableName
());
expect
(
Profile
.
rawAttributes
.
uid
.
referencesKey
).
to
.
equal
(
'id'
);
expect
(
Profile
.
rawAttributes
.
uid
.
allowNull
).
to
.
be
.
false
;
...
...
@@ -570,7 +570,7 @@ describe(Support.getTestDialectTeaser('HasOne'), function() {
User
.
hasOne
(
Profile
,
{
foreignKey
:
Profile
.
rawAttributes
.
user_id
});
expect
(
Profile
.
rawAttributes
.
user_id
).
to
.
be
.
defined
;
expect
(
Profile
.
rawAttributes
.
user_id
).
to
.
be
.
ok
;
expect
(
Profile
.
rawAttributes
.
user_id
.
references
).
to
.
equal
(
User
.
getTableName
());
expect
(
Profile
.
rawAttributes
.
user_id
.
referencesKey
).
to
.
equal
(
'uid'
);
expect
(
Profile
.
rawAttributes
.
user_id
.
allowNull
).
to
.
be
.
false
;
...
...
@@ -592,7 +592,7 @@ describe(Support.getTestDialectTeaser('HasOne'), function() {
User
.
hasOne
(
Project
,
{
foreignKey
:
{
allowNull
:
false
}});
expect
(
Project
.
rawAttributes
.
userUid
).
to
.
be
.
defined
;
expect
(
Project
.
rawAttributes
.
userUid
).
to
.
be
.
ok
;
expect
(
Project
.
rawAttributes
.
userUid
.
allowNull
).
to
.
be
.
false
;
expect
(
Project
.
rawAttributes
.
userUid
.
references
).
to
.
equal
(
User
.
getTableName
());
expect
(
Project
.
rawAttributes
.
userUid
.
referencesKey
).
to
.
equal
(
'uid'
);
...
...
test/integration/instance.validations.test.js
View file @
94f5e18
...
...
@@ -547,7 +547,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), function() {
var
successfulUser
=
User
.
build
({
name
:
'2'
});
return
successfulUser
.
validate
().
then
(
function
(
err
)
{
expect
(
err
).
not
.
to
.
be
.
defined
;
expect
(
err
).
to
.
be
.
un
defined
;
});
});
});
...
...
@@ -576,7 +576,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), function() {
expect
(
error
.
get
(
'name'
)[
0
].
message
).
to
.
equal
(
'Invalid username'
);
return
User
.
build
({
name
:
'no error'
}).
validate
().
then
(
function
(
errors
)
{
expect
(
errors
).
not
.
to
.
be
.
defined
;
expect
(
errors
).
to
.
be
.
un
defined
;
});
});
});
...
...
test/integration/model.test.js
View file @
94f5e18
...
...
@@ -2365,7 +2365,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
if
(
dialect
!==
'sqlite'
&&
current
.
dialect
.
supports
.
transactions
)
{
it
(
'supports multiple async transactions'
,
function
()
{
this
.
timeout
(
25
000
);
this
.
timeout
(
50
000
);
var
self
=
this
;
return
Support
.
prepareTransactionTest
(
this
.
sequelize
).
bind
({}).
then
(
function
(
sequelize
)
{
var
User
=
sequelize
.
define
(
'User'
,
{
username
:
Sequelize
.
STRING
});
...
...
test/integration/model/upsert.test.js
View file @
94f5e18
...
...
@@ -43,7 +43,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it
(
'works with upsert on id'
,
function
()
{
return
this
.
User
.
upsert
({
id
:
42
,
username
:
'john'
}).
bind
(
this
).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
not
.
to
.
be
.
defined
;
expect
(
created
).
to
.
be
.
un
defined
;
}
else
{
expect
(
created
).
to
.
be
.
ok
;
}
...
...
@@ -53,14 +53,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
}).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
not
.
to
.
be
.
defined
;
expect
(
created
).
to
.
be
.
un
defined
;
}
else
{
expect
(
created
).
not
.
to
.
be
.
ok
;
}
return
this
.
User
.
find
(
42
);
}).
then
(
function
(
user
)
{
expect
(
user
.
createdAt
).
to
.
be
.
defined
;
expect
(
user
.
createdAt
).
to
.
be
.
ok
;
expect
(
user
.
username
).
to
.
equal
(
'doe'
);
expect
(
user
.
updatedAt
).
to
.
be
.
afterTime
(
user
.
createdAt
);
});
...
...
@@ -69,7 +69,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it
(
'works with upsert on a composite key'
,
function
()
{
return
this
.
User
.
upsert
({
foo
:
'baz'
,
bar
:
19
,
username
:
'john'
}).
bind
(
this
).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
not
.
to
.
be
.
defined
;
expect
(
created
).
to
.
be
.
un
defined
;
}
else
{
expect
(
created
).
to
.
be
.
ok
;
}
...
...
@@ -79,14 +79,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
}).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
not
.
to
.
be
.
defined
;
expect
(
created
).
to
.
be
.
un
defined
;
}
else
{
expect
(
created
).
not
.
to
.
be
.
ok
;
}
return
this
.
User
.
find
({
where
:
{
foo
:
'baz'
,
bar
:
19
}});
}).
then
(
function
(
user
)
{
expect
(
user
.
createdAt
).
to
.
be
.
defined
;
expect
(
user
.
createdAt
).
to
.
be
.
ok
;
expect
(
user
.
username
).
to
.
equal
(
'doe'
);
expect
(
user
.
updatedAt
).
to
.
be
.
afterTime
(
user
.
createdAt
);
});
...
...
@@ -113,8 +113,8 @@ describe(Support.getTestDialectTeaser('Model'), function() {
]);
}).
spread
(
function
(
created1
,
created2
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created1
).
not
.
to
.
be
.
defined
;
expect
(
created2
).
not
.
to
.
be
.
defined
;
expect
(
created1
).
to
.
be
.
un
defined
;
expect
(
created2
).
to
.
be
.
un
defined
;
}
else
{
expect
(
created1
).
to
.
be
.
ok
;
expect
(
created2
).
to
.
be
.
ok
;
...
...
@@ -126,21 +126,21 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
}).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
not
.
to
.
be
.
defined
;
expect
(
created
).
to
.
be
.
un
defined
;
}
else
{
expect
(
created
).
not
.
to
.
be
.
ok
;
}
return
User
.
find
({
where
:
{
a
:
'a'
,
b
:
'b'
}});
}).
then
(
function
(
user1
)
{
expect
(
user1
.
createdAt
).
to
.
be
.
defined
;
expect
(
user1
.
createdAt
).
to
.
be
.
ok
;
expect
(
user1
.
username
).
to
.
equal
(
'doe'
);
expect
(
user1
.
updatedAt
).
to
.
be
.
afterTime
(
user1
.
createdAt
);
return
User
.
find
({
where
:
{
a
:
'a'
,
b
:
'a'
}});
}).
then
(
function
(
user2
)
{
// The second one should not be updated
expect
(
user2
.
createdAt
).
to
.
be
.
defined
;
expect
(
user2
.
createdAt
).
to
.
be
.
ok
;
expect
(
user2
.
username
).
to
.
equal
(
'curt'
);
expect
(
user2
.
updatedAt
).
to
.
equalTime
(
user2
.
createdAt
);
});
...
...
@@ -162,7 +162,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it
(
'works with BLOBs'
,
function
()
{
return
this
.
User
.
upsert
({
id
:
42
,
username
:
'john'
,
blob
:
new
Buffer
(
'kaj'
)
}).
bind
(
this
).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
not
.
to
.
be
.
defined
;
expect
(
created
).
to
.
be
.
un
defined
;
}
else
{
expect
(
created
).
to
.
be
.
ok
;
}
...
...
@@ -172,14 +172,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
}).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
not
.
to
.
be
.
defined
;
expect
(
created
).
to
.
be
.
un
defined
;
}
else
{
expect
(
created
).
not
.
to
.
be
.
ok
;
}
return
this
.
User
.
find
(
42
);
}).
then
(
function
(
user
)
{
expect
(
user
.
createdAt
).
to
.
be
.
defined
;
expect
(
user
.
createdAt
).
to
.
be
.
ok
;
expect
(
user
.
username
).
to
.
equal
(
'doe'
);
expect
(
user
.
blob
.
toString
()).
to
.
equal
(
'andrea'
);
expect
(
user
.
updatedAt
).
to
.
be
.
afterTime
(
user
.
createdAt
);
...
...
@@ -189,7 +189,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it
(
'works with .field'
,
function
()
{
return
this
.
User
.
upsert
({
id
:
42
,
baz
:
'foo'
}).
bind
(
this
).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
not
.
to
.
be
.
defined
;
expect
(
created
).
to
.
be
.
un
defined
;
}
else
{
expect
(
created
).
to
.
be
.
ok
;
}
...
...
@@ -199,7 +199,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
}).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
not
.
to
.
be
.
defined
;
expect
(
created
).
to
.
be
.
un
defined
;
}
else
{
expect
(
created
).
not
.
to
.
be
.
ok
;
}
...
...
test/integration/sequelize.transaction.test.js
View file @
94f5e18
...
...
@@ -139,7 +139,7 @@ describe(Support.getTestDialectTeaser('Sequelize#transaction'), function() {
return
self
.
Model
.
create
({
name
:
'omnom'
},
{
transaction
:
t1
}).
then
(
function
(
m1
)
{
return
Promise
.
all
([
self
.
Model
.
create
({
name
:
'omnom'
},
{
transaction
:
t2
}).
catch
(
function
(
err
)
{
expect
(
err
).
to
.
be
.
defined
;
expect
(
err
).
to
.
be
.
ok
;
return
t2
.
rollback
();
}),
Promise
.
delay
(
100
).
then
(
function
()
{
...
...
test/support.js
View file @
94f5e18
...
...
@@ -8,9 +8,10 @@ var fs = require('fs')
,
Config
=
require
(
__dirname
+
'/config/config'
)
,
chai
=
require
(
'chai'
)
,
expect
=
chai
.
expect
,
chaiAsPromised
=
require
(
'chai-as-promised'
);
,
chaiAsPromised
=
require
(
'chai-as-promised'
)
,
missingAssertions
=
require
(
'chai-missing-assertions'
);
chai
.
use
(
chaiAsPromised
);
chai
.
use
(
missingAssertions
);
// Make sure errors get thrown when testing
Sequelize
.
Promise
.
onPossiblyUnhandledRejection
(
function
(
e
,
promise
)
{
...
...
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