Add api docs for .not and .withContext

This commit is contained in:
Gregg Van Hove
2018-10-24 16:49:31 -07:00
parent 1b5e0c0c10
commit 5524207658
2 changed files with 64 additions and 0 deletions

View File

@@ -2801,10 +2801,25 @@ getJasmineRequireObj().Expectation = function(j$) {
}
}
/**
* Add some context for an {@link expect}
* @function
* @name matchers#withContext
* @param {String} message - Additional context to show when the matcher fails
* @return {matchers}
*/
Expectation.prototype.withContext = function withContext(message) {
return addFilter(this, new ContextAddingFilter(message));
};
/**
* Invert the matcher following this {@link expect}
* @member
* @name matchers#not
* @type {matchers}
* @example
* expect(something).not.toBe(true);
*/
Object.defineProperty(Expectation.prototype, 'not', {
get: function() {
return addFilter(this, syncNegatingFilter);
@@ -2828,10 +2843,27 @@ getJasmineRequireObj().Expectation = function(j$) {
}
}
/**
* Add some context for an {@link expectAsync}
* @function
* @name async-matchers#withContext
* @param {String} message - Additional context to show when the async matcher fails
* @return {async-matchers}
*/
AsyncExpectation.prototype.withContext = function withContext(message) {
return addFilter(this, new ContextAddingFilter(message));
};
/**
* Invert the matcher following this {@link expectAsync}
* @member
* @name async-matchers#not
* @type {async-matchers}
* @example
* await expectAsync(myPromise).not.toBeResolved();
* @example
* return expectAsync(myPromise).not.toBeResolved();
*/
Object.defineProperty(AsyncExpectation.prototype, 'not', {
get: function() {
return addFilter(this, asyncNegatingFilter);

View File

@@ -16,10 +16,25 @@ getJasmineRequireObj().Expectation = function(j$) {
}
}
/**
* Add some context for an {@link expect}
* @function
* @name matchers#withContext
* @param {String} message - Additional context to show when the matcher fails
* @return {matchers}
*/
Expectation.prototype.withContext = function withContext(message) {
return addFilter(this, new ContextAddingFilter(message));
};
/**
* Invert the matcher following this {@link expect}
* @member
* @name matchers#not
* @type {matchers}
* @example
* expect(something).not.toBe(true);
*/
Object.defineProperty(Expectation.prototype, 'not', {
get: function() {
return addFilter(this, syncNegatingFilter);
@@ -43,10 +58,27 @@ getJasmineRequireObj().Expectation = function(j$) {
}
}
/**
* Add some context for an {@link expectAsync}
* @function
* @name async-matchers#withContext
* @param {String} message - Additional context to show when the async matcher fails
* @return {async-matchers}
*/
AsyncExpectation.prototype.withContext = function withContext(message) {
return addFilter(this, new ContextAddingFilter(message));
};
/**
* Invert the matcher following this {@link expectAsync}
* @member
* @name async-matchers#not
* @type {async-matchers}
* @example
* await expectAsync(myPromise).not.toBeResolved();
* @example
* return expectAsync(myPromise).not.toBeResolved();
*/
Object.defineProperty(AsyncExpectation.prototype, 'not', {
get: function() {
return addFilter(this, asyncNegatingFilter);