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 59d48328
authored
Feb 06, 2014
by
Thanasis Polychronakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor remaining validation tests to support new Error pattern
1 parent
620fb0e3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
17 deletions
test/dao.validations.test.js
test/dao.validations.test.js
View file @
59d4832
...
@@ -306,7 +306,8 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
...
@@ -306,7 +306,8 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
Model
.
sync
({
force
:
true
}).
success
(
function
()
{
Model
.
sync
({
force
:
true
}).
success
(
function
()
{
Model
.
create
({
name
:
'World'
}).
success
(
function
(
model
)
{
Model
.
create
({
name
:
'World'
}).
success
(
function
(
model
)
{
model
.
updateAttributes
({
name
:
''
}).
error
(
function
(
err
)
{
model
.
updateAttributes
({
name
:
''
}).
error
(
function
(
err
)
{
expect
(
err
).
to
.
deep
.
equal
({
name
:
[
'String is empty'
]
})
expect
(
err
).
to
.
be
.
instanceOf
(
Error
)
expect
(
err
.
name
).
to
.
deep
.
equal
([
'String is empty'
]);
done
()
done
()
})
})
})
})
...
@@ -327,7 +328,8 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
...
@@ -327,7 +328,8 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
Model
.
sync
({
force
:
true
}).
success
(
function
()
{
Model
.
sync
({
force
:
true
}).
success
(
function
()
{
Model
.
create
({
name
:
'World'
}).
success
(
function
(
model
)
{
Model
.
create
({
name
:
'World'
}).
success
(
function
(
model
)
{
Model
.
update
({
name
:
''
},
{
id
:
1
}).
error
(
function
(
err
)
{
Model
.
update
({
name
:
''
},
{
id
:
1
}).
error
(
function
(
err
)
{
expect
(
err
).
to
.
deep
.
equal
({
name
:
[
'String is empty'
]
})
expect
(
err
).
to
.
be
.
instanceOf
(
Error
)
expect
(
err
.
name
).
to
.
deep
.
equal
([
'String is empty'
]);
done
()
done
()
})
})
})
})
...
@@ -405,7 +407,8 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
...
@@ -405,7 +407,8 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
User
.
sync
({
force
:
true
}).
success
(
function
()
{
User
.
sync
({
force
:
true
}).
success
(
function
()
{
User
.
create
({
id
:
'helloworld'
}).
error
(
function
(
err
)
{
User
.
create
({
id
:
'helloworld'
}).
error
(
function
(
err
)
{
expect
(
err
).
to
.
deep
.
equal
({
id
:
[
'Invalid integer'
]})
expect
(
err
).
to
.
be
.
instanceOf
(
Error
)
expect
(
err
.
id
).
to
.
deep
.
equal
([
'Invalid integer'
]);
done
()
done
()
})
})
})
})
...
@@ -425,7 +428,8 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
...
@@ -425,7 +428,8 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
User
.
sync
({
force
:
true
}).
success
(
function
()
{
User
.
sync
({
force
:
true
}).
success
(
function
()
{
User
.
create
({
username
:
'helloworldhelloworld'
}).
error
(
function
(
err
)
{
User
.
create
({
username
:
'helloworldhelloworld'
}).
error
(
function
(
err
)
{
expect
(
err
).
to
.
deep
.
equal
({
username
:
[
'Username must be an integer!'
]})
expect
(
err
).
to
.
be
.
instanceOf
(
Error
)
expect
(
err
.
username
).
to
.
deep
.
equal
([
'Username must be an integer!'
]);
done
()
done
()
})
})
})
})
...
@@ -451,7 +455,8 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
...
@@ -451,7 +455,8 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
it
(
'should emit an error when we try to enter in a string for the id key with validation arguments'
,
function
(
done
)
{
it
(
'should emit an error when we try to enter in a string for the id key with validation arguments'
,
function
(
done
)
{
this
.
User
.
create
({
id
:
'helloworld'
}).
error
(
function
(
err
)
{
this
.
User
.
create
({
id
:
'helloworld'
}).
error
(
function
(
err
)
{
expect
(
err
).
to
.
deep
.
equal
({
id
:
[
'ID must be an integer!'
]})
expect
(
err
).
to
.
be
.
instanceOf
(
Error
)
expect
(
err
.
id
).
to
.
deep
.
equal
([
'ID must be an integer!'
]);
done
()
done
()
})
})
})
})
...
@@ -459,8 +464,9 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
...
@@ -459,8 +464,9 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
it
(
'should emit an error when we try to enter in a string for an auto increment key through .build().validate()'
,
function
(
done
)
{
it
(
'should emit an error when we try to enter in a string for an auto increment key through .build().validate()'
,
function
(
done
)
{
var
user
=
this
.
User
.
build
({
id
:
'helloworld'
})
var
user
=
this
.
User
.
build
({
id
:
'helloworld'
})
user
.
validate
().
success
(
function
(
errors
)
{
user
.
validate
().
success
(
function
(
err
)
{
expect
(
errors
).
to
.
deep
.
equal
({
id
:
[
'ID must be an integer!'
]
})
expect
(
err
).
to
.
be
.
instanceOf
(
Error
)
expect
(
err
.
id
).
to
.
deep
.
equal
([
'ID must be an integer!'
]);
done
()
done
()
})
})
})
})
...
@@ -468,7 +474,8 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
...
@@ -468,7 +474,8 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
it
(
'should emit an error when we try to .save()'
,
function
(
done
)
{
it
(
'should emit an error when we try to .save()'
,
function
(
done
)
{
var
user
=
this
.
User
.
build
({
id
:
'helloworld'
})
var
user
=
this
.
User
.
build
({
id
:
'helloworld'
})
user
.
save
().
error
(
function
(
err
)
{
user
.
save
().
error
(
function
(
err
)
{
expect
(
err
).
to
.
deep
.
equal
({
id
:
[
'ID must be an integer!'
]
})
expect
(
err
).
to
.
be
.
instanceOf
(
Error
)
expect
(
err
.
id
).
to
.
deep
.
equal
([
'ID must be an integer!'
]);
done
()
done
()
})
})
})
})
...
@@ -523,9 +530,10 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
...
@@ -523,9 +530,10 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
User
User
.
build
({
age
:
-
1
})
.
build
({
age
:
-
1
})
.
validate
()
.
validate
()
.
success
(
function
(
errors
)
{
.
success
(
function
(
error
)
{
expect
(
errors
).
not
.
to
.
be
.
null
expect
(
error
).
not
.
to
.
be
.
null
expect
(
errors
).
to
.
deep
.
equal
({
age
:
[
'must be positive'
]
})
expect
(
error
).
to
.
be
.
instanceOf
(
Error
);
expect
(
error
.
age
).
to
.
deep
.
equal
([
"must be positive"
])
User
.
build
({
age
:
null
}).
validate
().
success
(
function
()
{
User
.
build
({
age
:
null
}).
validate
().
success
(
function
()
{
User
.
build
({
age
:
1
}).
validate
().
success
(
function
()
{
User
.
build
({
age
:
1
}).
validate
().
success
(
function
()
{
...
@@ -560,9 +568,10 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
...
@@ -560,9 +568,10 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
Foo
Foo
.
build
({
field1
:
null
,
field2
:
null
})
.
build
({
field1
:
null
,
field2
:
null
})
.
validate
()
.
validate
()
.
success
(
function
(
errors
)
{
.
success
(
function
(
error
)
{
expect
(
errors
).
not
.
to
.
be
.
null
expect
(
error
).
not
.
to
.
be
.
null
expect
(
errors
).
to
.
deep
.
equal
({
'xnor'
:
[
'xnor failed'
]
})
expect
(
error
).
to
.
be
.
instanceOf
(
Error
)
expect
(
error
.
xnor
).
to
.
deep
.
equal
([
'xnor failed'
]);
Foo
Foo
.
build
({
field1
:
33
,
field2
:
null
})
.
build
({
field1
:
33
,
field2
:
null
})
...
@@ -597,9 +606,10 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
...
@@ -597,9 +606,10 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
Foo
Foo
.
build
({
field1
:
null
,
field2
:
null
})
.
build
({
field1
:
null
,
field2
:
null
})
.
validate
()
.
validate
()
.
success
(
function
(
errors
)
{
.
success
(
function
(
error
)
{
expect
(
errors
).
not
.
to
.
be
.
null
expect
(
error
).
not
.
to
.
be
.
null
expect
(
errors
).
to
.
deep
.
equal
({
'xnor'
:
[
'xnor failed'
]
})
expect
(
error
).
to
.
be
.
instanceOf
(
Error
)
expect
(
error
.
xnor
).
to
.
deep
.
equal
([
'xnor failed'
]);
Foo
Foo
.
build
({
field1
:
33
,
field2
:
null
})
.
build
({
field1
:
33
,
field2
:
null
})
...
...
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