Skip to content

Commit

Permalink
Adds the matchOnOptions helper
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarnold committed Jun 3, 2013
1 parent 6343f95 commit 9a8c218
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ logs
Gemfile.lock
bin/
src/jquery.continuations.Docs/pak-WebContent.zip
docs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
return typeof(this[prop]) !== 'undefined' && predicate(this[prop]);
},
matchOnOption: function(prop, predicate) {
if(typeof(predicate) != 'function') {
predicate = function() { return true; };
}

return typeof(this.options[prop]) !== 'undefined' && predicate(this.options[prop]);
},
isCorrelated: function () {
return this.matchOnProperty('correlationId', function(id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,20 @@ describe('continuation tester', function() {
theContinuation.correlationId = '123';
expect(theContinuation.isCorrelated()).toEqual(true);
});

it('matching on options', function() {
theContinuation.options.myProperty = '123';
var match = theContinuation.matchOnOption('myProperty', function(x) { return x == '123' });

expect(match).toEqual(true);
});

it('matching on options (negative)', function() {
theContinuation.options.myProperty = '123';
var match = theContinuation.matchOnOption('myProperty', function(x) { return x == '345' });

expect(match).toEqual(false);
});
});

// And now for the error handling
Expand Down

0 comments on commit 9a8c218

Please sign in to comment.