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 b836799f
authored
Apr 12, 2012
by
sdepold
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/grayt0r/sequelize
into grayt0r-master
2 parents
f7bcdcc5
b1e5e328
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
lib/dao.js
spec-jasmine/dao.spec.js
lib/dao.js
View file @
b836799
...
@@ -224,6 +224,10 @@ module.exports = (function() {
...
@@ -224,6 +224,10 @@ module.exports = (function() {
this
.
validators
[
attribute
]
=
validators
this
.
validators
[
attribute
]
=
validators
}
}
DAO
.
prototype
.
toJSON
=
function
()
{
return
this
.
values
;
}
// private
// private
var
initAttributes
=
function
(
values
)
{
var
initAttributes
=
function
(
values
)
{
...
...
spec-jasmine/dao.spec.js
View file @
b836799
...
@@ -496,6 +496,56 @@ describe('DAO', function() {
...
@@ -496,6 +496,56 @@ describe('DAO', function() {
})
})
})
})
})
})
describe
(
'toJSON'
,
function
()
{
it
(
'returns an object containing all values'
,
function
()
{
var
User
=
sequelize
.
define
(
'User'
,
{
username
:
Sequelize
.
STRING
,
age
:
Sequelize
.
INTEGER
,
dob
:
Sequelize
.
DATE
,
isAdmin
:
Sequelize
.
BOOLEAN
},
{
timestamps
:
false
,
logging
:
false
})
Helpers
.
async
(
function
(
done
)
{
User
.
sync
({
force
:
true
}).
success
(
done
)
})
Helpers
.
async
(
function
(
done
)
{
var
user
=
User
.
build
({
username
:
'test.user'
,
age
:
99
,
dob
:
new
Date
(
1973
,
4
,
6
),
isAdmin
:
true
})
expect
(
user
.
toJSON
()).
toEqual
({
username
:
'test.user'
,
age
:
99
,
dob
:
new
Date
(
1973
,
4
,
6
),
isAdmin
:
true
,
id
:
null
})
done
()
})
})
it
(
'returns a response that can be stringified'
,
function
()
{
var
User
=
sequelize
.
define
(
'User'
,
{
username
:
Sequelize
.
STRING
,
age
:
Sequelize
.
INTEGER
,
dob
:
Sequelize
.
DATE
,
isAdmin
:
Sequelize
.
BOOLEAN
},
{
timestamps
:
false
,
logging
:
false
})
Helpers
.
async
(
function
(
done
)
{
User
.
sync
({
force
:
true
}).
success
(
done
)
})
Helpers
.
async
(
function
(
done
)
{
var
user
=
User
.
build
({
username
:
'test.user'
,
age
:
99
,
dob
:
new
Date
(
1973
,
4
,
6
),
isAdmin
:
true
})
expect
(
JSON
.
stringify
(
user
)).
toEqual
(
'{"username":"test.user","age":99,"dob":"1973-05-05T23:00:00.000Z","isAdmin":true,"id":null}'
)
done
()
})
})
it
(
'returns a response that can be stringified and then parsed'
,
function
()
{
var
User
=
sequelize
.
define
(
'User'
,
{
username
:
Sequelize
.
STRING
,
age
:
Sequelize
.
INTEGER
,
dob
:
Sequelize
.
DATE
,
isAdmin
:
Sequelize
.
BOOLEAN
},
{
timestamps
:
false
,
logging
:
false
})
Helpers
.
async
(
function
(
done
)
{
User
.
sync
({
force
:
true
}).
success
(
done
)
})
Helpers
.
async
(
function
(
done
)
{
var
user
=
User
.
build
({
username
:
'test.user'
,
age
:
99
,
dob
:
new
Date
(
1973
,
4
,
6
),
isAdmin
:
true
})
expect
(
JSON
.
parse
(
JSON
.
stringify
(
user
))).
toEqual
({
username
:
'test.user'
,
age
:
99
,
dob
:
"1973-05-05T23:00:00.000Z"
,
isAdmin
:
true
,
id
:
null
})
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