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 e4a65dff
authored
Jul 01, 2012
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
append the results of the emitters as arbitrary params to the callback of the query chainer
1 parent
dbc8b30e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletions
lib/query-chainer.js
spec/query-chainer.spec.js
lib/query-chainer.js
View file @
e4a65df
...
@@ -128,7 +128,7 @@ module.exports = (function() {
...
@@ -128,7 +128,7 @@ module.exports = (function() {
var
status
=
(
this
.
fails
.
length
==
0
?
'success'
:
'error'
)
var
status
=
(
this
.
fails
.
length
==
0
?
'success'
:
'error'
)
,
result
=
(
this
.
fails
.
length
==
0
?
this
[
resultsName
]
:
this
.
fails
)
,
result
=
(
this
.
fails
.
length
==
0
?
this
[
resultsName
]
:
this
.
fails
)
this
.
eventEmitter
.
emit
(
status
,
result
)
this
.
eventEmitter
.
emit
.
apply
(
this
.
eventEmitter
,
[
status
,
result
].
concat
(
result
)
)
}
}
}
}
...
...
spec/query-chainer.spec.js
View file @
e4a65df
...
@@ -76,6 +76,25 @@ describe('QueryChainer', function() {
...
@@ -76,6 +76,25 @@ describe('QueryChainer', function() {
emitter1
.
run
()
emitter1
.
run
()
emitter3
.
run
()
emitter3
.
run
()
})
})
it
(
"returns the result as an array and each result as part of the callback signature"
,
function
(
done
)
{
var
emitter1
=
new
CustomEventEmitter
(
function
(
e
)
{
e
.
emit
(
'success'
,
1
)
})
,
emitter2
=
new
CustomEventEmitter
(
function
(
e
)
{
e
.
emit
(
'success'
,
2
)
})
this
.
queryChainer
.
add
(
emitter1
)
this
.
queryChainer
.
add
(
emitter2
)
this
.
queryChainer
.
run
().
success
(
function
(
results
,
result1
,
result2
)
{
expect
(
result1
).
toBeDefined
()
expect
(
result2
).
toBeDefined
()
expect
(
result1
).
toEqual
(
1
)
expect
(
result2
).
toEqual
(
2
)
done
()
})
emitter2
.
run
()
emitter1
.
run
()
})
})
})
describe
(
'runSerially'
,
function
()
{
describe
(
'runSerially'
,
function
()
{
...
@@ -120,5 +139,21 @@ describe('QueryChainer', function() {
...
@@ -120,5 +139,21 @@ describe('QueryChainer', function() {
done
()
done
()
})
})
})
})
it
(
"returns the result as an array and each result as part of the callback signature"
,
function
(
done
)
{
var
emitter1
=
new
CustomEventEmitter
(
function
(
e
)
{
e
.
emit
(
'success'
,
1
)
})
,
emitter2
=
new
CustomEventEmitter
(
function
(
e
)
{
e
.
emit
(
'success'
,
2
)
})
this
.
queryChainer
.
add
(
emitter1
,
'run'
)
this
.
queryChainer
.
add
(
emitter2
,
'run'
)
this
.
queryChainer
.
runSerially
().
success
(
function
(
results
,
result1
,
result2
)
{
expect
(
result1
).
toBeDefined
()
expect
(
result2
).
toBeDefined
()
expect
(
result1
).
toEqual
(
1
)
expect
(
result2
).
toEqual
(
2
)
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