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 43f3efa9
authored
Aug 04, 2010
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
specs
1 parent
93efb3f8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
test/SequelizeTableTest.js
test/SequelizeTest.js
test/SequelizeTableTest.js
View file @
43f3efa
...
@@ -75,6 +75,7 @@ module.exports = {
...
@@ -75,6 +75,7 @@ module.exports = {
'findAll should return all items as class objects'
:
function
(
assert
,
beforeExit
)
{
'findAll should return all items as class objects'
:
function
(
assert
,
beforeExit
)
{
var
allFindAllTestItems
=
null
var
allFindAllTestItems
=
null
var
FindAllTest
=
s
.
define
(
'FindAllTest'
,
{})
var
FindAllTest
=
s
.
define
(
'FindAllTest'
,
{})
FindAllTest
.
drop
(
function
()
{
FindAllTest
.
drop
(
function
()
{
FindAllTest
.
sync
(
function
()
{
FindAllTest
.
sync
(
function
()
{
new
FindAllTest
({}).
save
(
function
()
{
new
FindAllTest
({}).
save
(
function
()
{
...
@@ -131,6 +132,35 @@ module.exports = {
...
@@ -131,6 +132,35 @@ module.exports = {
Day
.
hasMany
(
'HasManyBlubbs'
,
HasManyBlubb
)
Day
.
hasMany
(
'HasManyBlubbs'
,
HasManyBlubb
)
assert
.
isNotUndefined
(
new
Day
({
name
:
''
}).
HasManyBlubbs
)
assert
.
isNotUndefined
(
new
Day
({
name
:
''
}).
HasManyBlubbs
)
},
},
'hasMany findAll => crossAssociated'
:
function
(
assert
,
beforeExit
)
{
var
assoc
=
null
var
Character
=
s
.
define
(
'Character'
,
{})
var
Word
=
s
.
define
(
'Word'
,
{})
Character
.
hasMany
(
'Words'
,
Word
)
Word
.
hasMany
(
'Characters'
,
Character
)
Sequelize
.
chainQueries
([
{
drop
:
Character
},
{
drop
:
Word
},
{
prepareAssociations
:
Word
},
{
prepareAssociations
:
Character
},
{
sync
:
Word
},
{
sync
:
Character
}
],
function
()
{
var
Association
=
s
.
tables
.
CharactersWords
.
klass
Association
.
sync
(
function
()
{
var
w
=
new
Word
()
var
c1
=
new
Character
()
var
c2
=
new
Character
()
Sequelize
.
chainQueries
([{
save
:
w
},
{
save
:
c1
},
{
save
:
c2
}],
function
()
{
w
.
setCharacters
([
c1
,
c2
],
function
(
associations
)
{
assoc
=
associations
})
})
})
})
beforeExit
(
function
()
{
assert
.
isNotNull
(
assoc
)
assert
.
equal
(
assoc
.
length
,
2
)
})
},
'hasOne'
:
function
(
assert
)
{
'hasOne'
:
function
(
assert
)
{
var
HasOneBlubb
=
s
.
define
(
'HasOneBlubb'
,
{})
var
HasOneBlubb
=
s
.
define
(
'HasOneBlubb'
,
{})
Day
.
hasOne
(
'HasOneBlubb'
,
HasOneBlubb
)
Day
.
hasOne
(
'HasOneBlubb'
,
HasOneBlubb
)
...
...
test/SequelizeTest.js
View file @
43f3efa
...
@@ -71,5 +71,9 @@ module.exports = {
...
@@ -71,5 +71,9 @@ module.exports = {
'sqlQueryFor: delete'
:
function
(
assert
)
{
'sqlQueryFor: delete'
:
function
(
assert
)
{
var
query
=
Sequelize
.
sqlQueryFor
(
'delete'
,
{
table
:
'Foo'
,
where
:
"id=2"
})
var
query
=
Sequelize
.
sqlQueryFor
(
'delete'
,
{
table
:
'Foo'
,
where
:
"id=2"
})
assert
.
equal
(
query
,
"DELETE FROM Foo WHERE id=2 LIMIT 1"
)
assert
.
equal
(
query
,
"DELETE FROM Foo WHERE id=2 LIMIT 1"
)
},
'sqlQueryFor: delete wihtout limit'
:
function
(
assert
)
{
var
query
=
Sequelize
.
sqlQueryFor
(
'delete'
,
{
table
:
'Foo'
,
where
:
"id=2"
,
limit
:
null
})
assert
.
equal
(
query
,
"DELETE FROM Foo WHERE id=2"
)
}
}
}
}
\ 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