Added matchers: truthy, falsy, empty and notEmpty
This commit is contained in:
34
src/core/asymmetric_equality/NotEmpty.js
Normal file
34
src/core/asymmetric_equality/NotEmpty.js
Normal file
@@ -0,0 +1,34 @@
|
||||
getJasmineRequireObj().NotEmpty = function (j$) {
|
||||
|
||||
function NotEmpty() {}
|
||||
|
||||
NotEmpty.prototype.asymmetricMatch = function (other) {
|
||||
if (typeof other === 'string') {
|
||||
return other.length !== 0;
|
||||
}
|
||||
|
||||
if (other instanceof Array) {
|
||||
return other.length !== 0;
|
||||
}
|
||||
|
||||
if (typeof Map !== 'undefined' && other instanceof Map) {
|
||||
return other.size !== 0;
|
||||
}
|
||||
|
||||
if (typeof Set !== 'undefined' && other instanceof Set) {
|
||||
return other.size !== 0;
|
||||
}
|
||||
|
||||
if (other instanceof Object) {
|
||||
return Object.keys(other).length !== 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
NotEmpty.prototype.jasmineToString = function () {
|
||||
return '<jasmine.notEmpty>';
|
||||
};
|
||||
|
||||
return NotEmpty;
|
||||
};
|
||||
Reference in New Issue
Block a user