-
-
Notifications
You must be signed in to change notification settings - Fork 85
/
index.js
52 lines (46 loc) · 1.18 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import id from '../../../../lib/id';
/**
* Describes a test call inside a Vest suite.
* @param {String} suiteId Suite Id.
* @param {String} fieldName Name of the field being tested.
* @param {String} statement The message returned when failing.
* @param {Promise|Function} testFn The actual test callback or promise.
* @param {string} [group] The group in which the test runs.
*/
function VestTest({ suiteId, fieldName, statement, testFn, group }) {
Object.assign(this, {
failed: false,
fieldName,
id: id(),
isWarning: false,
statement,
suiteId,
testFn,
});
if (group) {
this.groupName = group;
}
}
/**
* @returns {Boolean} Current validity status of a test.
*/
VestTest.prototype.valueOf = function () {
return this.failed !== true;
};
/**
* Sets a test to failed.
* @returns {VestTest} Current instance.
*/
VestTest.prototype.fail = function () {
this.failed = true;
return this;
};
/**
* Sets a current test's `isWarning` to true.
* @returns {VestTest} Current instance.
*/
VestTest.prototype.warn = function () {
this.isWarning = true;
return this;
};
export default VestTest;