Skip to content

Commit 8cd7c94

Browse files
committed
Added a jsdoc example for withContext()
Fixes jasmine/jasmine.github.io#166
1 parent 6a6fa7b commit 8cd7c94

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

lib/jasmine-core/jasmine.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3667,19 +3667,24 @@ getJasmineRequireObj().Expectation = function(j$) {
36673667
}
36683668

36693669
/**
3670-
* Add some context for an {@link expect}
3670+
* Add some context to be included in matcher failures for an
3671+
* {@link expect|expectation}, so that it can be more easily distinguished
3672+
* from similar expectations.
36713673
* @function
36723674
* @name matchers#withContext
36733675
* @since 3.3.0
36743676
* @param {String} message - Additional context to show when the matcher fails
36753677
* @return {matchers}
3678+
* @example
3679+
* expect(things[0]).withContext('thing 0').toEqual('a');
3680+
* expect(things[1]).withContext('thing 1').toEqual('b');
36763681
*/
36773682
Expectation.prototype.withContext = function withContext(message) {
36783683
return addFilter(this, new ContextAddingFilter(message));
36793684
};
36803685

36813686
/**
3682-
* Invert the matcher following this {@link expect}
3687+
* Invert the matcher following this {@link expect|expectation}
36833688
* @member
36843689
* @name matchers#not
36853690
* @since 1.3.0

src/core/Expectation.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,24 @@ getJasmineRequireObj().Expectation = function(j$) {
1616
}
1717

1818
/**
19-
* Add some context for an {@link expect}
19+
* Add some context to be included in matcher failures for an
20+
* {@link expect|expectation}, so that it can be more easily distinguished
21+
* from similar expectations.
2022
* @function
2123
* @name matchers#withContext
2224
* @since 3.3.0
2325
* @param {String} message - Additional context to show when the matcher fails
2426
* @return {matchers}
27+
* @example
28+
* expect(things[0]).withContext('thing 0').toEqual('a');
29+
* expect(things[1]).withContext('thing 1').toEqual('b');
2530
*/
2631
Expectation.prototype.withContext = function withContext(message) {
2732
return addFilter(this, new ContextAddingFilter(message));
2833
};
2934

3035
/**
31-
* Invert the matcher following this {@link expect}
36+
* Invert the matcher following this {@link expect|expectation}
3237
* @member
3338
* @name matchers#not
3439
* @since 1.3.0

0 commit comments

Comments
 (0)