Skip to content

Commit

Permalink
Added a jsdoc example for withContext()
Browse files Browse the repository at this point in the history
  • Loading branch information
sgravrock committed Apr 16, 2024
1 parent 6a6fa7b commit 8cd7c94
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions lib/jasmine-core/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -3667,19 +3667,24 @@ getJasmineRequireObj().Expectation = function(j$) {
}

/**
* Add some context for an {@link expect}
* Add some context to be included in matcher failures for an
* {@link expect|expectation}, so that it can be more easily distinguished
* from similar expectations.
* @function
* @name matchers#withContext
* @since 3.3.0
* @param {String} message - Additional context to show when the matcher fails
* @return {matchers}
* @example
* expect(things[0]).withContext('thing 0').toEqual('a');
* expect(things[1]).withContext('thing 1').toEqual('b');
*/
Expectation.prototype.withContext = function withContext(message) {
return addFilter(this, new ContextAddingFilter(message));
};

/**
* Invert the matcher following this {@link expect}
* Invert the matcher following this {@link expect|expectation}
* @member
* @name matchers#not
* @since 1.3.0
Expand Down
9 changes: 7 additions & 2 deletions src/core/Expectation.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ getJasmineRequireObj().Expectation = function(j$) {
}

/**
* Add some context for an {@link expect}
* Add some context to be included in matcher failures for an
* {@link expect|expectation}, so that it can be more easily distinguished
* from similar expectations.
* @function
* @name matchers#withContext
* @since 3.3.0
* @param {String} message - Additional context to show when the matcher fails
* @return {matchers}
* @example
* expect(things[0]).withContext('thing 0').toEqual('a');
* expect(things[1]).withContext('thing 1').toEqual('b');
*/
Expectation.prototype.withContext = function withContext(message) {
return addFilter(this, new ContextAddingFilter(message));
};

/**
* Invert the matcher following this {@link expect}
* Invert the matcher following this {@link expect|expectation}
* @member
* @name matchers#not
* @since 1.3.0
Expand Down

0 comments on commit 8cd7c94

Please sign in to comment.