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 deca3c5b
authored
Dec 17, 2014
by
Matheus Bratfisch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing tests of #2746 to use promisses style
1 parent
b29184d1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
85 deletions
test/hooks.test.js
test/hooks.test.js
View file @
deca3c5
...
@@ -5334,7 +5334,7 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
...
@@ -5334,7 +5334,7 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
describe
(
'multiple 1:M'
,
function
()
{
describe
(
'multiple 1:M'
,
function
()
{
describe
(
'cascade'
,
function
()
{
describe
(
'cascade'
,
function
()
{
beforeEach
(
function
(
done
)
{
beforeEach
(
function
()
{
var
self
=
this
;
var
self
=
this
;
this
.
Projects
=
this
.
sequelize
.
define
(
'Project'
,
{
this
.
Projects
=
this
.
sequelize
.
define
(
'Project'
,
{
title
:
DataTypes
.
STRING
title
:
DataTypes
.
STRING
...
@@ -5357,17 +5357,11 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
...
@@ -5357,17 +5357,11 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
this
.
MiniTasks
.
belongsTo
(
this
.
Projects
,
{
hooks
:
true
});
this
.
MiniTasks
.
belongsTo
(
this
.
Projects
,
{
hooks
:
true
});
this
.
MiniTasks
.
belongsTo
(
this
.
Tasks
,
{
hooks
:
true
});
this
.
MiniTasks
.
belongsTo
(
this
.
Tasks
,
{
hooks
:
true
});
this
.
Projects
.
sync
({
force
:
true
}).
success
(
function
()
{
return
this
.
sequelize
.
sync
({
force
:
true
});
self
.
Tasks
.
sync
({
force
:
true
}).
success
(
function
()
{
self
.
MiniTasks
.
sync
({
force
:
true
}).
success
(
function
()
{
done
();
});
});
});
});
});
describe
(
'#remove'
,
function
()
{
describe
(
'#remove'
,
function
()
{
it
(
'with no errors'
,
function
(
done
)
{
it
(
'with no errors'
,
function
()
{
var
self
=
this
var
self
=
this
,
beforeProject
=
false
,
beforeProject
=
false
,
afterProject
=
false
,
afterProject
=
false
...
@@ -5407,24 +5401,25 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
...
@@ -5407,24 +5401,25 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
fn
();
fn
();
});
});
this
.
Projects
.
create
({
title
:
'New Project'
}).
success
(
function
(
project
)
{
return
this
.
sequelize
.
Promise
.
all
([
self
.
MiniTasks
.
create
({
mini_title
:
'New MiniTask'
}).
success
(
function
(
minitask
)
{
this
.
Projects
.
create
({
title
:
'New Project'
}),
project
.
addMiniTask
(
minitask
).
success
(
function
()
{
this
.
MiniTasks
.
create
({
mini_title
:
'New MiniTask'
})
project
.
destroy
().
success
(
function
(
err
)
{
]).
bind
(
this
).
spread
(
function
(
project
,
minitask
)
{
expect
(
beforeProject
).
to
.
be
.
true
;
return
project
.
addMiniTask
(
minitask
)
;
expect
(
afterProject
).
to
.
be
.
true
;
}).
then
(
function
(
project
)
{
expect
(
beforeTask
).
to
.
be
.
false
;
return
project
.
destroy
()
;
expect
(
afterTask
).
to
.
be
.
false
;
}).
then
(
function
()
{
expect
(
beforeMiniTask
).
to
.
be
.
true
;
expect
(
beforeProject
).
to
.
be
.
true
;
expect
(
afterMiniTask
).
to
.
be
.
true
;
expect
(
afterProject
).
to
.
be
.
true
;
done
()
;
expect
(
beforeTask
).
to
.
be
.
false
;
})
;
expect
(
afterTask
).
to
.
be
.
false
;
})
;
expect
(
beforeMiniTask
).
to
.
be
.
true
;
})
;
expect
(
afterMiniTask
).
to
.
be
.
true
;
});
});
});
});
it
(
'with errors'
,
function
(
done
)
{
it
(
'with errors'
,
function
()
{
var
self
=
this
var
self
=
this
,
beforeProject
=
false
,
beforeProject
=
false
,
afterProject
=
false
,
afterProject
=
false
...
@@ -5464,21 +5459,20 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
...
@@ -5464,21 +5459,20 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
fn
();
fn
();
});
});
this
.
Projects
.
create
({
title
:
'New Project'
}).
success
(
function
(
project
)
{
return
this
.
sequelize
.
Promise
.
all
([
self
.
MiniTasks
.
create
({
mini_title
:
'New MiniTask'
}).
success
(
function
(
minitask
)
{
this
.
Projects
.
create
({
title
:
'New Project'
}),
project
.
addMiniTask
(
minitask
).
success
(
function
()
{
this
.
MiniTasks
.
create
({
mini_title
:
'New MiniTask'
})
project
.
destroy
().
error
(
function
(
err
)
{
]).
bind
(
this
).
spread
(
function
(
project
,
minitask
)
{
expect
(
err
).
to
.
be
.
instanceOf
(
Error
);
return
project
.
addMiniTask
(
minitask
);
expect
(
beforeProject
).
to
.
be
.
true
;
}).
then
(
function
(
project
)
{
expect
(
afterProject
).
to
.
be
.
true
;
return
project
.
destroy
();
expect
(
beforeTask
).
to
.
be
.
false
;
}).
catch
(
function
()
{
expect
(
afterTask
).
to
.
be
.
false
;
expect
(
beforeProject
).
to
.
be
.
true
;
expect
(
beforeMiniTask
).
to
.
be
.
true
;
expect
(
afterProject
).
to
.
be
.
true
;
expect
(
afterMiniTask
).
to
.
be
.
false
;
expect
(
beforeTask
).
to
.
be
.
false
;
done
();
expect
(
afterTask
).
to
.
be
.
false
;
});
expect
(
beforeMiniTask
).
to
.
be
.
true
;
});
expect
(
afterMiniTask
).
to
.
be
.
false
;
});
});
});
});
});
});
});
...
@@ -5488,7 +5482,7 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
...
@@ -5488,7 +5482,7 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
describe
(
'multiple 1:M sequential hooks'
,
function
()
{
describe
(
'multiple 1:M sequential hooks'
,
function
()
{
describe
(
'cascade'
,
function
()
{
describe
(
'cascade'
,
function
()
{
beforeEach
(
function
(
done
)
{
beforeEach
(
function
()
{
var
self
=
this
;
var
self
=
this
;
this
.
Projects
=
this
.
sequelize
.
define
(
'Project'
,
{
this
.
Projects
=
this
.
sequelize
.
define
(
'Project'
,
{
title
:
DataTypes
.
STRING
title
:
DataTypes
.
STRING
...
@@ -5511,17 +5505,11 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
...
@@ -5511,17 +5505,11 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
this
.
MiniTasks
.
belongsTo
(
this
.
Projects
,
{
hooks
:
true
});
this
.
MiniTasks
.
belongsTo
(
this
.
Projects
,
{
hooks
:
true
});
this
.
MiniTasks
.
belongsTo
(
this
.
Tasks
,
{
hooks
:
true
});
this
.
MiniTasks
.
belongsTo
(
this
.
Tasks
,
{
hooks
:
true
});
this
.
Projects
.
sync
({
force
:
true
}).
success
(
function
()
{
return
this
.
sequelize
.
sync
({
force
:
true
});
self
.
Tasks
.
sync
({
force
:
true
}).
success
(
function
()
{
self
.
MiniTasks
.
sync
({
force
:
true
}).
success
(
function
()
{
done
();
});
});
});
});
});
describe
(
'#remove'
,
function
()
{
describe
(
'#remove'
,
function
()
{
it
(
'with no errors'
,
function
(
done
)
{
it
(
'with no errors'
,
function
()
{
var
self
=
this
var
self
=
this
,
beforeProject
=
false
,
beforeProject
=
false
,
afterProject
=
false
,
afterProject
=
false
...
@@ -5561,28 +5549,29 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
...
@@ -5561,28 +5549,29 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
fn
();
fn
();
});
});
this
.
Projects
.
create
({
title
:
'New Project'
}).
success
(
function
(
project
)
{
self
.
Tasks
.
create
({
title
:
'New Task'
}).
success
(
function
(
task
)
{
return
this
.
sequelize
.
Promise
.
all
([
self
.
MiniTasks
.
create
({
mini_title
:
'New MiniTask'
}).
success
(
function
(
minitask
)
{
this
.
Projects
.
create
({
title
:
'New Project'
}),
task
.
addMiniTask
(
minitask
).
success
(
function
()
{
this
.
Tasks
.
create
({
title
:
'New Task'
}),
project
.
addTask
(
task
).
success
(
function
()
{
this
.
MiniTasks
.
create
({
mini_title
:
'New MiniTask'
})
project
.
destroy
().
success
(
function
()
{
]).
bind
(
this
).
spread
(
function
(
project
,
task
,
minitask
)
{
expect
(
beforeProject
).
to
.
be
.
true
;
return
this
.
sequelize
.
Promise
.
all
([
expect
(
afterProject
).
to
.
be
.
true
;
task
.
addMiniTask
(
minitask
),
expect
(
beforeTask
).
to
.
be
.
true
;
project
.
addTask
(
task
)
expect
(
afterTask
).
to
.
be
.
true
;
]).
return
(
project
);
expect
(
beforeMiniTask
).
to
.
be
.
true
;
}).
then
(
function
(
project
)
{
expect
(
afterMiniTask
).
to
.
be
.
true
;
return
project
.
destroy
();
done
();
}).
then
(
function
()
{
});
expect
(
beforeProject
).
to
.
be
.
true
;
});
expect
(
afterProject
).
to
.
be
.
true
;
});
expect
(
beforeTask
).
to
.
be
.
true
;
});
expect
(
afterTask
).
to
.
be
.
true
;
});
expect
(
beforeMiniTask
).
to
.
be
.
true
;
expect
(
afterMiniTask
).
to
.
be
.
true
;
});
});
});
});
it
(
'with errors'
,
function
(
done
)
{
it
(
'with errors'
,
function
()
{
var
self
=
this
var
self
=
this
,
beforeProject
=
false
,
beforeProject
=
false
,
afterProject
=
false
,
afterProject
=
false
...
@@ -5622,24 +5611,24 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
...
@@ -5622,24 +5611,24 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
fn
();
fn
();
});
});
this
.
Projects
.
create
({
title
:
'New Project'
}).
success
(
function
(
project
)
{
return
this
.
sequelize
.
Promise
.
all
([
self
.
Tasks
.
create
({
title
:
'New Task'
}).
success
(
function
(
task
)
{
this
.
Projects
.
create
({
title
:
'New Project'
}),
self
.
MiniTasks
.
create
({
mini_title
:
'New MiniTask'
}).
success
(
function
(
minitask
)
{
this
.
Tasks
.
create
({
title
:
'New Task'
}),
task
.
addMiniTask
(
minitask
).
success
(
function
()
{
this
.
MiniTasks
.
create
({
mini_title
:
'New MiniTask'
})
project
.
addTask
(
task
).
success
(
function
(
)
{
]).
bind
(
this
).
spread
(
function
(
project
,
task
,
minitask
)
{
project
.
destroy
().
error
(
function
()
{
return
this
.
sequelize
.
Promise
.
all
([
expect
(
beforeProject
).
to
.
be
.
true
;
task
.
addMiniTask
(
minitask
),
expect
(
afterProject
).
to
.
be
.
true
;
project
.
addTask
(
task
)
expect
(
beforeTask
).
to
.
be
.
true
;
]).
return
(
project
)
;
expect
(
afterTask
).
to
.
be
.
false
;
}).
then
(
function
(
project
)
{
expect
(
beforeMiniTask
).
to
.
be
.
false
;
return
project
.
destroy
()
;
expect
(
afterMiniTask
).
to
.
be
.
false
;
}).
catch
(
function
()
{
done
()
;
expect
(
beforeProject
).
to
.
be
.
true
;
})
;
expect
(
afterProject
).
to
.
be
.
true
;
})
;
expect
(
beforeTask
).
to
.
be
.
true
;
})
;
expect
(
afterTask
).
to
.
be
.
false
;
})
;
expect
(
beforeMiniTask
).
to
.
be
.
false
;
})
;
expect
(
afterMiniTask
).
to
.
be
.
false
;
});
});
});
});
});
});
...
...
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