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 905f7a55
authored
Dec 09, 2011
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored specs
1 parent
5d7f96eb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
15 deletions
spec/query-generator.mysql.spec.js
spec/query-generator.mysql.spec.js
View file @
905f7a5
...
@@ -3,28 +3,46 @@ var config = require("./config/config")
...
@@ -3,28 +3,46 @@ var config = require("./config/config")
,
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
,
{
logging
:
false
})
,
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
,
{
logging
:
false
})
,
Helpers
=
new
(
require
(
"./config/helpers"
))(
sequelize
)
,
Helpers
=
new
(
require
(
"./config/helpers"
))(
sequelize
)
,
QueryGenerator
=
require
(
"../lib/connectors/mysql/query-generator"
)
,
QueryGenerator
=
require
(
"../lib/connectors/mysql/query-generator"
)
,
util
=
require
(
"util"
)
describe
(
'QueryGenerator'
,
function
()
{
describe
(
'QueryGenerator'
,
function
()
{
beforeEach
(
function
()
{
Helpers
.
sync
()
})
beforeEach
(
function
()
{
Helpers
.
sync
()
})
afterEach
(
function
()
{
Helpers
.
drop
()
})
afterEach
(
function
()
{
Helpers
.
drop
()
})
describe
(
'hashToWhereConditions'
,
function
()
{
var
suites
=
{
it
(
"should correctly transform array into IN"
,
function
()
{
'hashToWhereConditions'
:
[
expect
(
{
QueryGenerator
.
hashToWhereConditions
({
id
:
[
1
,
2
,
3
]
})
arguments
:
[{
id
:
[
1
,
2
,
3
]
}],
).
toEqual
(
expectation
:
"`id` IN (1,2,3)"
"`id` IN (1,2,3)"
}
)
],
'selectQuery'
:
[
{
arguments
:
[
'foo'
,
{
attributes
:
[[
'count(*)'
,
'count'
]]
}],
expectation
:
'SELECT count(*) as `count` FROM `foo`;'
}
]
}
Sequelize
.
Utils
.
_
.
each
(
suites
,
function
(
tests
,
suiteTitle
)
{
describe
(
suiteTitle
,
function
()
{
tests
.
forEach
(
function
(
test
)
{
var
title
=
'correctly returns '
+
test
.
expectation
+
' for '
+
test
.
arguments
it
(
title
,
function
()
{
var
conditions
=
QueryGenerator
[
suiteTitle
].
apply
(
null
,
test
.
arguments
)
expect
(
conditions
).
toEqual
(
test
.
expectation
)
})
})
})
})
describe
(
'selectQuery'
,
function
()
{
it
(
"should correctly convert arrays into aliases"
,
function
()
{
expect
(
QueryGenerator
.
selectQuery
(
'foo'
,
{
attributes
:
[[
'count(*)'
,
'count'
]]
})
).
toEqual
(
'SELECT count(*) as `count` FROM `foo`;'
)
})
})
})
})
// //describe('addIndexQuery', function() {
// // it("only returns the basics if only necessary parameters are passed", function() {
// // expect(
// // QueryGenerator.addIndexQuery('User', ['username', 'isAdmin'])
// // ).toEqual(
// // 'CREATE INDEX user_username_is_admin ON User username, isAdmin'
// // )
// // })
// //})
})
})
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