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 5700c122
authored
Jul 23, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils is converted
1 parent
8fc9e329
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
0 deletions
test/utils.test.js
test/utils.test.js
View file @
5700c12
...
...
@@ -43,4 +43,97 @@ describe("Utils", function() {
expect
(
result
).
to
.
match
(
/.*alert
\(
2
\)
.*/
)
})
})
describe
(
'argsArePrimaryKeys'
,
function
()
{
it
(
"doesn't detect primary keys if primareyKeys and values have different lengths"
,
function
()
{
expect
(
Utils
.
argsArePrimaryKeys
([
1
,
2
,
3
],
[
1
])).
to
.
be
.
false
})
it
(
"doesn't detect primary keys if primary keys are hashes or arrays"
,
function
()
{
expect
(
Utils
.
argsArePrimaryKeys
([[]],
[
1
])).
to
.
be
.
false
})
it
(
'detects primary keys if length is correct and data types are matching'
,
function
()
{
expect
(
Utils
.
argsArePrimaryKeys
([
1
,
2
,
3
],
[
"INTEGER"
,
"INTEGER"
,
"INTEGER"
])).
to
.
be
.
true
})
it
(
"detects primary keys if primary keys are dates and lengths are matching"
,
function
()
{
expect
(
Utils
.
argsArePrimaryKeys
([
new
Date
()],
[
'foo'
])).
to
.
be
.
true
})
})
describe
(
'underscore'
,
function
()
{
describe
(
'underscoredIf'
,
function
()
{
it
(
'is defined'
,
function
()
{
expect
(
Utils
.
_
.
underscoredIf
).
to
.
be
.
ok
})
it
(
'underscores if second param is true'
,
function
()
{
expect
(
Utils
.
_
.
underscoredIf
(
'fooBar'
,
true
)).
to
.
equal
(
'foo_bar'
)
})
it
(
"doesn't underscore if second param is false"
,
function
()
{
expect
(
Utils
.
_
.
underscoredIf
(
'fooBar'
,
false
)).
to
.
equal
(
'fooBar'
)
})
})
describe
(
'camelizeIf'
,
function
()
{
it
(
'is defined'
,
function
()
{
expect
(
Utils
.
_
.
camelizeIf
).
to
.
be
.
ok
})
it
(
'camelizes if second param is true'
,
function
()
{
expect
(
Utils
.
_
.
camelizeIf
(
'foo_bar'
,
true
)).
to
.
equal
(
'fooBar'
)
})
it
(
"doesn't camelize if second param is false"
,
function
()
{
expect
(
Utils
.
_
.
underscoredIf
(
'fooBar'
,
true
)).
to
.
equal
(
'foo_bar'
)
})
})
})
describe
(
'isHash'
,
function
()
{
it
(
'doesn\'t match arrays'
,
function
()
{
expect
(
Utils
.
isHash
([])).
to
.
be
.
false
})
it
(
'doesn\'t match null'
,
function
()
{
expect
(
Utils
.
isHash
(
null
)).
to
.
be
.
false
})
it
(
'matches plain objects'
,
function
()
{
var
values
=
{
'name'
:
{
'first'
:
'Foo'
,
'last'
:
'Bar'
}
}
expect
(
Utils
.
isHash
(
values
)).
to
.
be
.
true
})
it
(
'matches plain objects with length property/key'
,
function
()
{
var
values
=
{
'name'
:
{
'first'
:
'Foo'
,
'last'
:
'Bar'
},
'length'
:
1
}
expect
(
Utils
.
isHash
(
values
)).
to
.
be
.
true
})
})
describe
(
'format'
,
function
()
{
it
(
'should format where clause correctly when the value is truthy'
,
function
()
{
var
where
=
[
'foo = ?'
,
1
]
expect
(
Utils
.
format
(
where
)).
to
.
equal
(
'foo = 1'
)
})
it
(
'should format where clause correctly when the value is false'
,
function
()
{
var
where
=
[
'foo = ?'
,
0
]
expect
(
Utils
.
format
(
where
)).
to
.
equal
(
'foo = 0'
)
})
})
})
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