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 ae64f89e
authored
Sep 22, 2014
by
overlookmotel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests made sync
1 parent
0b16c9ef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
26 deletions
test/hooks.test.js
test/hooks.test.js
View file @
ae64f89
...
...
@@ -4323,7 +4323,7 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
});
describe
(
'#define'
,
function
()
{
before
(
function
(
done
)
{
before
(
function
()
{
this
.
sequelize
.
addHook
(
'beforeDefine'
,
function
(
attributes
,
options
)
{
options
.
modelName
=
'bar'
;
options
.
name
.
plural
=
'barrs'
;
...
...
@@ -4335,39 +4335,32 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
});
this
.
model
=
this
.
sequelize
.
define
(
'foo'
,
{
name
:
DataTypes
.
STRING
});
done
();
});
it
(
'beforeDefine hook can change model name'
,
function
(
done
)
{
it
(
'beforeDefine hook can change model name'
,
function
()
{
expect
(
this
.
model
.
name
).
to
.
equal
(
'bar'
);
done
();
});
it
(
'beforeDefine hook can alter options'
,
function
(
done
)
{
it
(
'beforeDefine hook can alter options'
,
function
()
{
expect
(
this
.
model
.
options
.
name
.
plural
).
to
.
equal
(
'barrs'
);
done
();
});
it
(
'beforeDefine hook can alter attributes'
,
function
(
done
)
{
it
(
'beforeDefine hook can alter attributes'
,
function
()
{
expect
(
this
.
model
.
rawAttributes
.
type
).
to
.
be
.
ok
;
done
();
});
it
(
'afterDefine hook can alter options'
,
function
(
done
)
{
it
(
'afterDefine hook can alter options'
,
function
()
{
expect
(
this
.
model
.
options
.
name
.
singular
).
to
.
equal
(
'barr'
);
done
();
});
after
(
function
(
done
)
{
after
(
function
()
{
this
.
sequelize
.
options
.
hooks
=
{};
this
.
sequelize
.
modelManager
.
removeDAO
(
this
.
model
);
done
();
});
});
describe
(
'#instantiate'
,
function
()
{
before
(
function
(
done
)
{
before
(
function
()
{
Sequelize
.
addHook
(
'beforeInstantiate'
,
function
(
config
,
options
)
{
config
.
database
=
'db2'
;
options
.
host
=
'server9'
;
...
...
@@ -4378,28 +4371,22 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
});
this
.
seq
=
new
Sequelize
(
'db'
,
'user'
,
'pass'
,
{});
done
();
});
it
(
'beforeInstantiate hook can alter config'
,
function
(
done
)
{
it
(
'beforeInstantiate hook can alter config'
,
function
()
{
expect
(
this
.
seq
.
config
.
database
).
to
.
equal
(
'db2'
);
done
();
});
it
(
'beforeInstantiate hook can alter options'
,
function
(
done
)
{
it
(
'beforeInstantiate hook can alter options'
,
function
()
{
expect
(
this
.
seq
.
options
.
host
).
to
.
equal
(
'server9'
);
done
();
});
it
(
'afterInstantiate hook can alter options'
,
function
(
done
)
{
it
(
'afterInstantiate hook can alter options'
,
function
()
{
expect
(
this
.
seq
.
options
.
protocol
).
to
.
equal
(
'udp'
);
done
();
});
after
(
function
(
done
)
{
after
(
function
()
{
Sequelize
.
options
.
hooks
=
{};
done
();
});
});
...
...
@@ -4427,9 +4414,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
});
});
afterEach
(
function
(
done
)
{
afterEach
(
function
()
{
this
.
sequelize
.
options
.
hooks
=
{};
done
();
});
});
...
...
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