mirror of
https://github.com/chaijs/chai
synced 2024-11-15 00:07:11 +00:00
style: rename target
argument to subject
Most assertions use the term "target" to refer to the object under test, but a few assertions also had a `target` argument, resulting in an overloaded term that was difficult to document. This commit renames every `target` argument to `subject`.
This commit is contained in:
parent
a515ece48a
commit
dce6415d0a
1 changed files with 23 additions and 23 deletions
|
@ -2153,14 +2153,14 @@ module.exports = function (chai, _) {
|
|||
* @name change
|
||||
* @alias changes
|
||||
* @alias Change
|
||||
* @param {String} target
|
||||
* @param {String} subject
|
||||
* @param {String} property name _optional_
|
||||
* @param {String} message _optional_
|
||||
* @namespace BDD
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function assertChanges (target, prop, msg) {
|
||||
function assertChanges (subject, prop, msg) {
|
||||
if (msg) flag(this, 'message', msg);
|
||||
var fn = flag(this, 'object')
|
||||
, flagMsg = flag(this, 'message')
|
||||
|
@ -2169,16 +2169,16 @@ module.exports = function (chai, _) {
|
|||
|
||||
var initial;
|
||||
if (!prop) {
|
||||
new Assertion(target, flagMsg, ssfi, true).is.a('function');
|
||||
initial = target();
|
||||
new Assertion(subject, flagMsg, ssfi, true).is.a('function');
|
||||
initial = subject();
|
||||
} else {
|
||||
new Assertion(target, flagMsg, ssfi, true).to.have.property(prop);
|
||||
initial = target[prop];
|
||||
new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
|
||||
initial = subject[prop];
|
||||
}
|
||||
|
||||
fn();
|
||||
|
||||
var final = prop === undefined || prop === null ? target() : target[prop];
|
||||
var final = prop === undefined || prop === null ? subject() : subject[prop];
|
||||
var msgObj = prop === undefined || prop === null ? initial : '.' + prop;
|
||||
|
||||
// This gets flagged because of the .by(delta) assertion
|
||||
|
@ -2199,7 +2199,7 @@ module.exports = function (chai, _) {
|
|||
Assertion.addMethod('changes', assertChanges);
|
||||
|
||||
/**
|
||||
* ### .increase(target[, property[, message]])
|
||||
* ### .increase(subject[, property[, message]])
|
||||
*
|
||||
* Asserts that a function increases a numeric object property.
|
||||
*
|
||||
|
@ -2217,14 +2217,14 @@ module.exports = function (chai, _) {
|
|||
* @name increase
|
||||
* @alias increases
|
||||
* @alias Increase
|
||||
* @param {String|Function} target
|
||||
* @param {String|Function} subject
|
||||
* @param {String} property name _optional_
|
||||
* @param {String} message _optional_
|
||||
* @namespace BDD
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function assertIncreases (target, prop, msg) {
|
||||
function assertIncreases (subject, prop, msg) {
|
||||
if (msg) flag(this, 'message', msg);
|
||||
var fn = flag(this, 'object')
|
||||
, flagMsg = flag(this, 'message')
|
||||
|
@ -2233,11 +2233,11 @@ module.exports = function (chai, _) {
|
|||
|
||||
var initial;
|
||||
if (!prop) {
|
||||
new Assertion(target, flagMsg, ssfi, true).is.a('function');
|
||||
initial = target();
|
||||
new Assertion(subject, flagMsg, ssfi, true).is.a('function');
|
||||
initial = subject();
|
||||
} else {
|
||||
new Assertion(target, flagMsg, ssfi, true).to.have.property(prop);
|
||||
initial = target[prop];
|
||||
new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
|
||||
initial = subject[prop];
|
||||
}
|
||||
|
||||
// Make sure that the target is a number
|
||||
|
@ -2245,7 +2245,7 @@ module.exports = function (chai, _) {
|
|||
|
||||
fn();
|
||||
|
||||
var final = prop === undefined || prop === null ? target() : target[prop];
|
||||
var final = prop === undefined || prop === null ? subject() : subject[prop];
|
||||
var msgObj = prop === undefined || prop === null ? initial : '.' + prop;
|
||||
|
||||
flag(this, 'deltaMsgObj', msgObj);
|
||||
|
@ -2265,7 +2265,7 @@ module.exports = function (chai, _) {
|
|||
Assertion.addMethod('increases', assertIncreases);
|
||||
|
||||
/**
|
||||
* ### .decrease(target[, property[, message]])
|
||||
* ### .decrease(subject[, property[, message]])
|
||||
*
|
||||
* Asserts that a function decreases a numeric object property.
|
||||
*
|
||||
|
@ -2283,14 +2283,14 @@ module.exports = function (chai, _) {
|
|||
* @name decrease
|
||||
* @alias decreases
|
||||
* @alias Decrease
|
||||
* @param {String|Function} target
|
||||
* @param {String|Function} subject
|
||||
* @param {String} property name _optional_
|
||||
* @param {String} message _optional_
|
||||
* @namespace BDD
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function assertDecreases (target, prop, msg) {
|
||||
function assertDecreases (subject, prop, msg) {
|
||||
if (msg) flag(this, 'message', msg);
|
||||
var fn = flag(this, 'object')
|
||||
, flagMsg = flag(this, 'message')
|
||||
|
@ -2299,11 +2299,11 @@ module.exports = function (chai, _) {
|
|||
|
||||
var initial;
|
||||
if (!prop) {
|
||||
new Assertion(target, flagMsg, ssfi, true).is.a('function');
|
||||
initial = target();
|
||||
new Assertion(subject, flagMsg, ssfi, true).is.a('function');
|
||||
initial = subject();
|
||||
} else {
|
||||
new Assertion(target, flagMsg, ssfi, true).to.have.property(prop);
|
||||
initial = target[prop];
|
||||
new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
|
||||
initial = subject[prop];
|
||||
}
|
||||
|
||||
// Make sure that the target is a number
|
||||
|
@ -2311,7 +2311,7 @@ module.exports = function (chai, _) {
|
|||
|
||||
fn();
|
||||
|
||||
var final = prop === undefined || prop === null ? target() : target[prop];
|
||||
var final = prop === undefined || prop === null ? subject() : subject[prop];
|
||||
var msgObj = prop === undefined || prop === null ? initial : '.' + prop;
|
||||
|
||||
flag(this, 'deltaMsgObj', msgObj);
|
||||
|
|
Loading…
Reference in a new issue