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 4f0efb34
authored
Mar 01, 2016
by
Sushant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests to verify changes saved in hooks persists
1 parent
fe94906b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
0 deletions
test/integration/hooks/create.test.js
test/integration/hooks/updateAttributes.test.js
test/integration/hooks/create.test.js
View file @
4f0efb3
...
@@ -102,6 +102,55 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
...
@@ -102,6 +102,55 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
});
});
});
});
});
});
describe
(
'preserves changes to instance'
,
function
()
{
it
(
'beforeValidate'
,
function
(){
var
hookCalled
=
0
;
this
.
User
.
beforeValidate
(
function
(
user
,
options
)
{
user
.
mood
=
'happy'
;
hookCalled
++
;
});
return
this
.
User
.
create
({
mood
:
'sad'
,
username
:
'leafninja'
}).
then
(
function
(
user
)
{
expect
(
user
.
mood
).
to
.
equal
(
'happy'
);
expect
(
user
.
username
).
to
.
equal
(
'leafninja'
);
expect
(
hookCalled
).
to
.
equal
(
1
);
});
});
it
(
'afterValidate'
,
function
()
{
var
hookCalled
=
0
;
this
.
User
.
afterValidate
(
function
(
user
,
options
)
{
user
.
mood
=
'neutral'
;
hookCalled
++
;
});
return
this
.
User
.
create
({
mood
:
'sad'
,
username
:
'fireninja'
}).
then
(
function
(
user
)
{
expect
(
user
.
mood
).
to
.
equal
(
'neutral'
);
expect
(
user
.
username
).
to
.
equal
(
'fireninja'
);
expect
(
hookCalled
).
to
.
equal
(
1
);
});
});
it
(
'beforeCreate'
,
function
(){
var
hookCalled
=
0
;
this
.
User
.
beforeCreate
(
function
(
user
,
options
)
{
user
.
mood
=
'happy'
;
hookCalled
++
;
});
return
this
.
User
.
create
({
username
:
'akira'
}).
then
(
function
(
user
)
{
expect
(
user
.
mood
).
to
.
equal
(
'happy'
);
expect
(
user
.
username
).
to
.
equal
(
'akira'
);
expect
(
hookCalled
).
to
.
equal
(
1
);
});
});
});
});
});
});
});
test/integration/hooks/updateAttributes.test.js
View file @
4f0efb3
...
@@ -78,6 +78,37 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
...
@@ -78,6 +78,37 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
});
});
});
});
});
});
describe
(
'preserves changes to instance'
,
function
()
{
it
(
'beforeValidate'
,
function
(){
this
.
User
.
beforeValidate
(
function
(
user
,
options
)
{
user
.
mood
=
'happy'
;
});
return
this
.
User
.
create
({
username
:
'fireninja'
,
mood
:
'invalid'
}).
then
(
function
(
user
)
{
return
user
.
updateAttributes
({
username
:
'hero'
});
}).
then
(
function
(
user
)
{
expect
(
user
.
username
).
to
.
equal
(
'hero'
);
expect
(
user
.
mood
).
to
.
equal
(
'happy'
);
});
});
it
(
'afterValidate'
,
function
()
{
this
.
User
.
afterValidate
(
function
(
user
,
options
)
{
user
.
mood
=
'sad'
;
});
return
this
.
User
.
create
({
username
:
'fireninja'
,
mood
:
'nuetral'
}).
then
(
function
(
user
)
{
return
user
.
updateAttributes
({
username
:
'spider'
});
}).
then
(
function
(
user
)
{
expect
(
user
.
username
).
to
.
equal
(
'spider'
);
expect
(
user
.
mood
).
to
.
equal
(
'sad'
);
});
});
});
});
});
});
});
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