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 e0804c74
authored
Dec 30, 2013
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test for simple nested hasMany -> belongsTo include
1 parent
16e66c8d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
7 deletions
test/include.test.js
test/include.test.js
View file @
e0804c7
...
@@ -17,6 +17,7 @@ chai.use(datetime)
...
@@ -17,6 +17,7 @@ chai.use(datetime)
chai
.
Assertion
.
includeStack
=
true
chai
.
Assertion
.
includeStack
=
true
describe
(
Support
.
getTestDialectTeaser
(
"Include"
),
function
()
{
describe
(
Support
.
getTestDialectTeaser
(
"Include"
),
function
()
{
describe
(
'find'
,
function
()
{
it
(
'should support a simple nested belongsTo -> belongsTo include'
,
function
(
done
)
{
it
(
'should support a simple nested belongsTo -> belongsTo include'
,
function
(
done
)
{
var
Task
=
this
.
sequelize
.
define
(
'Task'
,
{})
var
Task
=
this
.
sequelize
.
define
(
'Task'
,
{})
,
User
=
this
.
sequelize
.
define
(
'User'
,
{})
,
User
=
this
.
sequelize
.
define
(
'User'
,
{})
...
@@ -46,7 +47,9 @@ describe(Support.getTestDialectTeaser("Include"), function () {
...
@@ -46,7 +47,9 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
Task
.
find
({
Task
.
find
({
id
:
results
.
task
.
id
,
where
:
{
id
:
results
.
task
.
id
},
include
:
[
include
:
[
{
model
:
User
,
include
:
[
{
model
:
User
,
include
:
[
{
model
:
Group
}
{
model
:
Group
}
...
@@ -62,7 +65,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
...
@@ -62,7 +65,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
})
})
})
})
it
(
'should support a simple nested hasOne -> hasOne include'
,
function
(
done
)
{
it
(
'should support a simple nested hasOne -> hasOne include'
,
function
(
done
)
{
var
Task
=
this
.
sequelize
.
define
(
'Task'
,
{})
var
Task
=
this
.
sequelize
.
define
(
'Task'
,
{})
,
User
=
this
.
sequelize
.
define
(
'User'
,
{})
,
User
=
this
.
sequelize
.
define
(
'User'
,
{})
,
Group
=
this
.
sequelize
.
define
(
'Group'
,
{})
,
Group
=
this
.
sequelize
.
define
(
'Group'
,
{})
...
@@ -91,7 +94,9 @@ it('should support a simple nested hasOne -> hasOne include', function (done) {
...
@@ -91,7 +94,9 @@ it('should support a simple nested hasOne -> hasOne include', function (done) {
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
Group
.
find
({
Group
.
find
({
id
:
results
.
group
.
id
,
where
:
{
id
:
results
.
group
.
id
},
include
:
[
include
:
[
{
model
:
User
,
include
:
[
{
model
:
User
,
include
:
[
{
model
:
Task
}
{
model
:
Task
}
...
@@ -121,7 +126,9 @@ it('should support a simple nested hasOne -> hasOne include', function (done) {
...
@@ -121,7 +126,9 @@ it('should support a simple nested hasOne -> hasOne include', function (done) {
User
.
create
().
done
(
callback
)
User
.
create
().
done
(
callback
)
},
},
projects
:
function
(
callback
)
{
projects
:
function
(
callback
)
{
Project
.
bulkCreate
([{},
{}]).
done
(
callback
)
Project
.
bulkCreate
([{},
{}]).
done
(
function
()
{
Project
.
findAll
().
done
(
callback
)
})
},
},
tasks
:
[
'projects'
,
function
(
callback
,
results
)
{
tasks
:
[
'projects'
,
function
(
callback
,
results
)
{
Task
.
bulkCreate
([
Task
.
bulkCreate
([
...
@@ -129,9 +136,36 @@ it('should support a simple nested hasOne -> hasOne include', function (done) {
...
@@ -129,9 +136,36 @@ it('should support a simple nested hasOne -> hasOne include', function (done) {
{
ProjectId
:
results
.
projects
[
1
].
id
},
{
ProjectId
:
results
.
projects
[
1
].
id
},
{
ProjectId
:
results
.
projects
[
0
].
id
},
{
ProjectId
:
results
.
projects
[
0
].
id
},
{
ProjectId
:
results
.
projects
[
1
].
id
}
{
ProjectId
:
results
.
projects
[
1
].
id
}
]).
done
(
callback
)
]).
done
(
function
()
{
Task
.
findAll
().
done
(
callback
)
})
}],
userTasks
:
[
'user'
,
'tasks'
,
function
(
callback
,
results
)
{
results
.
user
.
setTasks
(
results
.
tasks
).
done
(
callback
)
}]
}]
},
done
);
},
function
(
err
,
results
)
{
});
User
.
find
({
where
:
{
id
:
results
.
user
.
id
},
include
:
[
{
model
:
Task
,
include
:
[
{
model
:
Project
}
]}
]
}).
done
(
function
(
err
,
user
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
user
.
tasks
).
to
.
be
.
ok
expect
(
user
.
tasks
.
length
).
to
.
equal
(
4
)
user
.
tasks
.
forEach
(
function
(
task
)
{
expect
(
task
.
project
).
to
.
be
.
ok
})
done
()
})
})
})
})
})
})
})
})
\ No newline at end of file
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