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 4b85088b
authored
Dec 14, 2011
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more sqlite specs
1 parent
7b018d50
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
56 deletions
spec/sqlite/model-factory.spec.js
spec/sqlite/model-factory.spec.js
View file @
4b85088
...
@@ -37,70 +37,88 @@ describe('ModelFactory', function() {
...
@@ -37,70 +37,88 @@ describe('ModelFactory', function() {
}).
error
(
function
(
err
){
console
.
log
(
err
)
})
}).
error
(
function
(
err
){
console
.
log
(
err
)
})
})
})
})
})
it
(
'should allow the creation of an object with options as attribute'
,
function
()
{
var
Person
=
sequelize
.
define
(
'Person'
,
{
name
:
Sequelize
.
STRING
,
options
:
Sequelize
.
TEXT
})
Helpers
.
async
(
function
(
done
)
{
Person
.
sync
({
force
:
true
}).
success
(
done
)
})
Helpers
.
async
(
function
(
done
)
{
var
options
=
JSON
.
stringify
({
foo
:
'bar'
,
bar
:
'foo'
})
Helpers
.
Factories
.
Model
(
'Person'
,
{
name
:
'John Doe'
,
options
:
options
},
function
(
people
)
{
expect
(
people
[
0
].
options
).
toEqual
(
options
)
done
()
})
})
})
})
})
////////// find //////////////
////////// find //////////////
//
// describe('.find', function() {
describe
(
'.find'
,
function
()
{
// beforeEach(function() {
beforeEach
(
function
()
{
// Helpers.Factories.User({name: 'user', bio: 'foobar'}, null, 2)
Helpers
.
Factories
.
User
({
name
:
'user'
,
bio
:
'foobar'
},
null
,
2
)
// })
})
//
// it("should make aliased attributes available", function() {
it
(
"finds normal lookups"
,
function
()
{
// Helpers.async(function(done) {
Helpers
.
async
(
function
(
done
)
{
// User.find({ where: 'id = 1', attributes: ['id', ['name', 'username']] }).success(function(user) {
User
.
find
({
where
:
{
name
:
'user'
}
}).
success
(
function
(
user
)
{
// expect(user.username).toEqual('user')
expect
(
user
.
name
).
toEqual
(
'user'
)
// done()
done
()
// })
})
// })
})
// })
})
// })
//
it
(
"should make aliased attributes available"
,
function
()
{
Helpers
.
async
(
function
(
done
)
{
User
.
find
({
where
:
{
name
:
'user'
},
attributes
:
[
'id'
,
[
'name'
,
'username'
]]
}).
success
(
function
(
user
)
{
expect
(
user
.
username
).
toEqual
(
'user'
)
done
()
})
})
})
})
////////// all //////////////
////////// all //////////////
//
// describe('.all', function() {
describe
(
'.all'
,
function
()
{
// beforeEach(function() {
beforeEach
(
function
()
{
// Helpers.Factories.User({name: 'user', bio: 'foobar'}, null, 2)
Helpers
.
Factories
.
User
({
name
:
'user'
,
bio
:
'foobar'
},
null
,
2
)
// })
})
//
// it("should return all users", function() {
it
(
"should return all users"
,
function
()
{
// Helpers.async(function(done) {
Helpers
.
async
(
function
(
done
)
{
// User.all().on('success', function(users) {
User
.
all
().
on
(
'success'
,
function
(
users
)
{
// done()
done
()
// expect(users.length).toEqual(2)
expect
(
users
.
length
).
toEqual
(
2
)
// }).on('failure', function(err) { console.log(err) })
}).
on
(
'failure'
,
function
(
err
)
{
console
.
log
(
err
)
})
// })
})
// })
})
// })
})
//
///////// create ////////////
//
// describe('.create with options', function() {
// var Person = sequelize.define('Person', { name: Sequelize.STRING, options: Sequelize.TEXT })
//
// it('should allow the creation of an object with options as attribute', function() {
// var options = JSON.stringify({ foo: 'bar', bar: 'foo' })
// Helpers.Factories.Model('Person', {name: 'John Doe', options: options}, function(people) {
// expect(people[0].options).toEqual(options)
// })
// })
// })
//
////////// min //////////////
////////// min //////////////
//
// describe('.min', function() {
// describe('.min', function() {
//
it("should return the min value", function() {
//
it("should return the min value", function() {
//
for(var i = 2; i < 5; i++) Helpers.Factories.User({ age: i })
//
for(var i = 2; i < 5; i++) Helpers.Factories.User({ age: i })
//
//
Helpers.async(function(done) {
//
Helpers.async(function(done) {
//
User.min('age').on('success', function(min) {
//
User.min('age').on('success', function(min) {
//
expect(min).toEqual(2); done()
//
expect(min).toEqual(2); done()
//
})
//
})
//
})
//
})
//
})
//
})
// })
// })
//
////////// max //////////////
////////// max //////////////
//
//
// describe('.max', function() {
// describe('.max', function() {
...
...
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