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 5193b0d6
authored
Jul 05, 2012
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored test
1 parent
2c30c2c1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
spec/dao-factory.spec.js
spec/dao-factory.spec.js
View file @
5193b0d
...
@@ -8,7 +8,7 @@ if(typeof require === 'function') {
...
@@ -8,7 +8,7 @@ if(typeof require === 'function') {
buster
.
spec
.
expose
()
buster
.
spec
.
expose
()
dialects
.
forEach
(
function
(
dialect
)
{
dialects
.
forEach
(
function
(
dialect
)
{
describe
(
'DAO@'
+
dialect
,
function
()
{
describe
(
'DAO
Factory
@'
+
dialect
,
function
()
{
before
(
function
(
done
)
{
before
(
function
(
done
)
{
var
self
=
this
var
self
=
this
...
@@ -17,7 +17,7 @@ dialects.forEach(function(dialect) {
...
@@ -17,7 +17,7 @@ dialects.forEach(function(dialect) {
})
})
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
{
type
:
Sequelize
.
STRING
}
,
username
:
Sequelize
.
STRING
,
secretValue
:
Sequelize
.
STRING
secretValue
:
Sequelize
.
STRING
})
})
...
@@ -25,6 +25,7 @@ dialects.forEach(function(dialect) {
...
@@ -25,6 +25,7 @@ dialects.forEach(function(dialect) {
.
getQueryInterface
()
.
getQueryInterface
()
.
dropAllTables
()
.
dropAllTables
()
.
success
(
function
()
{
.
success
(
function
()
{
self
.
sequelize
.
daoFactoryManager
.
daos
=
[]
self
.
User
self
.
User
.
sync
({
force
:
true
})
.
sync
({
force
:
true
})
.
success
(
done
)
.
success
(
done
)
...
@@ -36,29 +37,34 @@ dialects.forEach(function(dialect) {
...
@@ -36,29 +37,34 @@ dialects.forEach(function(dialect) {
})
})
describe
(
'create with whitelist'
,
function
()
{
describe
(
'create with whitelist'
,
function
()
{
var
data
=
{
before
(
function
()
{
username
:
'Peter'
,
this
.
data
=
{
secretValue
:
'42'
username
:
'Peter'
,
}
secretValue
:
'42'
}
})
it
(
'should only store the values passed in the witelist'
,
function
(
done
)
{
it
(
'should only store the values passed in the witelist'
,
function
(
done
)
{
var
self
=
this
;
var
self
=
this
;
this
.
User
.
create
(
data
,
[
'username'
]).
success
(
function
(
user
)
{
this
.
User
.
create
(
this
.
data
,
[
'username'
]).
success
(
function
(
user
)
{
self
.
User
.
find
(
user
.
id
).
success
(
function
(
_user
)
{
self
.
User
.
find
(
user
.
id
).
success
(
function
(
_user
)
{
expect
(
_user
.
username
).
toEqual
(
data
.
username
);
expect
(
_user
.
username
).
toEqual
(
self
.
data
.
username
);
expect
(
_user
.
secretValue
).
not
.
toEqual
(
data
.
secretValue
);
expect
(
_user
.
secretValue
).
not
.
toEqual
(
self
.
data
.
secretValue
);
done
();
expect
(
_user
.
secretValue
).
toEqual
(
null
);
done
();
})
})
})
})
})
})
it
(
'should store all values if no whitelist is specified'
,
function
(
done
)
{
it
(
'should store all values if no whitelist is specified'
,
function
(
done
)
{
var
self
=
this
;
var
self
=
this
;
this
.
User
.
create
(
data
).
success
(
function
(
user
)
{
this
.
User
.
create
(
this
.
data
).
success
(
function
(
user
)
{
self
.
User
.
find
(
user
.
id
).
success
(
function
(
_user
)
{
self
.
User
.
find
(
user
.
id
).
success
(
function
(
_user
)
{
expect
(
_user
.
username
).
toEqual
(
data
.
username
);
expect
(
_user
.
username
).
toEqual
(
self
.
data
.
username
);
expect
(
_user
.
secretValue
).
toEqual
(
data
.
secretValue
);
expect
(
_user
.
secretValue
).
toEqual
(
self
.
data
.
secretValue
);
done
();
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