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 82f88ac8
authored
Jan 07, 2014
by
maximeCony
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests
1 parent
c56a9afe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
0 deletions
test/dao-factory.test.js
test/dao-factory.test.js
View file @
82f88ac
...
...
@@ -1660,4 +1660,96 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
})
describe
(
'paranoid is true and where is an array'
,
function
()
{
beforeEach
(
function
(
done
)
{
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
},
{
paranoid
:
true
})
this
.
Project
=
this
.
sequelize
.
define
(
'Project'
,
{
title
:
DataTypes
.
STRING
},
{
paranoid
:
true
})
this
.
Project
.
hasMany
(
this
.
User
)
this
.
User
.
hasMany
(
this
.
Project
)
var
self
=
this
this
.
sequelize
.
sync
({
force
:
true
}).
success
(
function
()
{
self
.
User
.
bulkCreate
([{
username
:
'leia'
},
{
username
:
'luke'
},
{
username
:
'vader'
}]).
success
(
function
()
{
self
.
Project
.
bulkCreate
([{
title
:
'republic'
},{
title
:
'empire'
}]).
success
(
function
()
{
self
.
User
.
findAll
().
success
(
function
(
users
){
self
.
Project
.
findAll
().
success
(
function
(
projects
){
var
leia
=
users
[
0
]
,
luke
=
users
[
1
]
,
vader
=
users
[
2
]
,
republic
=
projects
[
0
]
,
empire
=
projects
[
1
]
leia
.
setProjects
([
republic
]).
success
(
function
(){
luke
.
setProjects
([
republic
]).
success
(
function
(){
vader
.
setProjects
([
empire
]).
success
(
function
(){
leia
.
destroy
().
success
(
function
()
{
done
()
})
})
})
})
})
})
})
})
})
})
it
(
'should not fail with an include'
,
function
(
done
)
{
var
tableName
=
'"'
+
this
.
Project
.
tableName
+
'"'
this
.
User
.
findAll
({
where
:
[
tableName
+
'."title" = \'republic\' '
],
include
:
[
{
model
:
this
.
Project
}
]
}).
success
(
function
(
users
){
try
{
expect
(
users
.
length
).
to
.
be
.
equal
(
1
)
expect
(
users
[
0
].
username
).
to
.
be
.
equal
(
'luke'
)
done
()
}
catch
(
e
){
done
(
e
)
}
}).
error
(
done
)
})
it
(
'should not overwrite a specified deletedAt'
,
function
(
done
)
{
var
tableName
=
'"'
+
this
.
User
.
tableName
+
'"'
this
.
User
.
findAll
({
where
:
[
tableName
+
'."deletedAt" IS NOT NULL '
],
include
:
[
{
model
:
this
.
Project
}
]
}).
success
(
function
(
users
){
try
{
expect
(
users
.
length
).
to
.
be
.
equal
(
1
)
expect
(
users
[
0
].
username
).
to
.
be
.
equal
(
'leia'
)
done
()
}
catch
(
e
){
done
(
e
)
}
}).
error
(
done
)
})
})
})
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