Merge branch 'master' of https://github.com/sjolicoeur/jasmine into sjolicoeur-master

- Merges #1460 from @sjolicoeur
This commit is contained in:
Gregg Van Hove
2018-02-15 15:47:29 -08:00
11 changed files with 429 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
getJasmineRequireObj().Empty = function (j$) {
function Empty() {}
Empty.prototype.asymmetricMatch = function (other) {
if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) {
return other.length === 0;
}
if (j$.isMap(other) || j$.isSet(other)) {
return other.size === 0;
}
if (j$.isObject_(other)) {
return Object.keys(other).length === 0;
}
return false;
};
Empty.prototype.jasmineToString = function () {
return '<jasmine.empty>';
};
return Empty;
};

View File

@@ -0,0 +1,14 @@
getJasmineRequireObj().Falsy = function(j$) {
function Falsy() {}
Falsy.prototype.asymmetricMatch = function(other) {
return !other;
};
Falsy.prototype.jasmineToString = function() {
return '<jasmine.falsy>';
};
return Falsy;
};

View File

@@ -0,0 +1,26 @@
getJasmineRequireObj().NotEmpty = function (j$) {
function NotEmpty() {}
NotEmpty.prototype.asymmetricMatch = function (other) {
if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) {
return other.length !== 0;
}
if (j$.isMap(other) || j$.isSet(other)) {
return other.size !== 0;
}
if (j$.isObject_(other)) {
return Object.keys(other).length !== 0;
}
return false;
};
NotEmpty.prototype.jasmineToString = function () {
return '<jasmine.notEmpty>';
};
return NotEmpty;
};

View File

@@ -0,0 +1,14 @@
getJasmineRequireObj().Truthy = function(j$) {
function Truthy() {}
Truthy.prototype.asymmetricMatch = function(other) {
return !!other;
};
Truthy.prototype.jasmineToString = function() {
return '<jasmine.truthy>';
};
return Truthy;
};

View File

@@ -148,6 +148,38 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return new j$.Anything();
};
/**
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
* that will succeed if the actual value being compared is `true` or anything truthy.
* @name jasmine.truthy
* @function
*/
j$.truthy = function() {return new j$.Truthy();};
/**
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
* that will succeed if the actual value being compared is `null`, `undefined`, `0`, `false` or anything falsey.
* @name jasmine.falsy
* @function
*/
j$.falsy = function() {return new j$.Falsy();};
/**
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
* that will succeed if the actual value being compared is empty.
* @name jasmine.empty
* @function
*/
j$.empty = function() {return new j$.Empty();};
/**
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
* that will succeed if the actual value being compared is not empty.
* @name jasmine.notEmpty
* @function
*/
j$.notEmpty = function() {return new j$.NotEmpty();};
/**
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
* that will succeed if the actual value being compared contains at least the keys and values.

View File

@@ -63,6 +63,11 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
j$.ObjectPath = jRequire.ObjectPath(j$);
j$.GlobalErrors = jRequire.GlobalErrors(j$);
j$.Truthy = jRequire.Truthy(j$);
j$.Falsy = jRequire.Falsy(j$);
j$.Empty = jRequire.Empty(j$);
j$.NotEmpty = jRequire.NotEmpty(j$);
j$.matchers = jRequire.requireMatchers(jRequire, j$);
return j$;