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 c9994c31
authored
Dec 15, 2011
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved specs
1 parent
a85bd251
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
40 deletions
spec/model.spec.js
test/Model/build.js
spec/model.spec.js
View file @
c9994c3
...
@@ -247,4 +247,43 @@ describe('Model', function() {
...
@@ -247,4 +247,43 @@ describe('Model', function() {
});
});
});
});
})
})
describe
(
'build'
,
function
()
{
var
User
=
null
var
setup
=
function
()
{
Helpers
.
async
(
function
(
done
)
{
User
=
sequelize
.
define
(
'User'
,
{
name
:
Sequelize
.
STRING
,
bio
:
Sequelize
.
TEXT
})
User
.
sync
({
force
:
true
}).
success
(
done
)
})
}
beforeEach
(
function
()
{
Helpers
.
dropAllTables
();
setup
()
})
afterEach
(
function
()
{
Helpers
.
dropAllTables
()
})
it
(
"doesn't create database entries"
,
function
()
{
Helpers
.
async
(
function
(
done
)
{
User
.
build
({
name
:
'John Wayne'
,
bio
:
'noot'
})
User
.
all
().
success
(
function
(
users
)
{
expect
(
users
.
length
).
toEqual
(
0
)
done
()
})
})
})
it
(
"fills the objects with default values"
,
function
()
{
var
Task
=
sequelize
.
define
(
'Task'
+
config
.
rand
(),
{
title
:
{
type
:
Sequelize
.
STRING
,
defaultValue
:
'a task!'
},
foo
:
{
type
:
Sequelize
.
INTEGER
,
defaultValue
:
2
},
bar
:
{
type
:
Sequelize
.
DATE
},
foobar
:
{
type
:
Sequelize
.
TEXT
,
defaultValue
:
'asd'
},
flag
:
{
type
:
Sequelize
.
BOOLEAN
,
defaultValue
:
false
}
})
expect
(
Task
.
build
().
title
).
toEqual
(
'a task!'
)
expect
(
Task
.
build
().
foo
).
toEqual
(
2
)
expect
(
Task
.
build
().
bar
).
toEqual
(
null
)
expect
(
Task
.
build
().
foobar
).
toEqual
(
'asd'
)
expect
(
Task
.
build
().
flag
).
toEqual
(
false
)
})
})
})
})
test/Model/build.js
deleted
100644 → 0
View file @
a85bd25
var
assert
=
require
(
"assert"
)
,
config
=
require
(
"./../config"
)
,
Sequelize
=
require
(
"./../../index"
)
,
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
,
{
logging
:
false
,
define
:
{
charset
:
'latin1'
}})
var
initUsers
=
function
(
num
,
callback
)
{
var
User
=
sequelize
.
define
(
'User'
+
config
.
rand
(),
{
name
:
Sequelize
.
STRING
,
bio
:
Sequelize
.
TEXT
})
,
users
=
[]
User
.
sync
({
force
:
true
}).
on
(
'success'
,
function
()
{
while
(
num
--
)
users
.
push
(
User
.
build
({
name
:
'user'
+
num
,
bio
:
'foobar'
}))
callback
(
users
,
User
)
})
}
module
.
exports
=
{
'build should not create database entries'
:
function
(
exit
)
{
initUsers
(
10
,
function
(
users
,
User
)
{
assert
.
eql
(
users
.
length
,
10
)
User
.
all
().
on
(
'success'
,
function
(
users
)
{
assert
.
eql
(
users
.
length
,
0
)
exit
(
function
(){})
})
})
},
'build should fill the object with default values'
:
function
()
{
var
Task
=
sequelize
.
define
(
'Task'
+
config
.
rand
(),
{
title
:
{
type
:
Sequelize
.
STRING
,
defaultValue
:
'a task!'
},
foo
:
{
type
:
Sequelize
.
INTEGER
,
defaultValue
:
2
},
bar
:
{
type
:
Sequelize
.
DATE
},
foobar
:
{
type
:
Sequelize
.
TEXT
,
defaultValue
:
'asd'
},
flag
:
{
type
:
Sequelize
.
BOOLEAN
,
defaultValue
:
false
}
})
assert
.
eql
(
Task
.
build
().
title
,
'a task!'
)
assert
.
eql
(
Task
.
build
().
foo
,
2
)
assert
.
eql
(
Task
.
build
().
bar
,
null
)
assert
.
eql
(
Task
.
build
().
foobar
,
'asd'
)
assert
.
eql
(
Task
.
build
().
flag
,
false
)
}
}
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