Renamed jasmine.exactly to jasmine.is, for similarity with toBe
This commit is contained in:
@@ -113,7 +113,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
|
||||
j$.Falsy = jRequire.Falsy(j$);
|
||||
j$.Empty = jRequire.Empty(j$);
|
||||
j$.NotEmpty = jRequire.NotEmpty(j$);
|
||||
j$.Exactly = jRequire.Exactly(j$);
|
||||
j$.Is = jRequire.Is(j$);
|
||||
|
||||
j$.matchers = jRequire.requireMatchers(jRequire, j$);
|
||||
j$.asyncMatchers = jRequire.requireAsyncMatchers(jRequire, j$);
|
||||
@@ -458,12 +458,12 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher}
|
||||
* that passes if the actual value is the same as the sample as determined
|
||||
* by the `===` operator.
|
||||
* @name jasmine.exactly
|
||||
* @name jasmine.is
|
||||
* @function
|
||||
* @param {Object} sample - The value to compare the actual to.
|
||||
*/
|
||||
j$.exactly = function(sample) {
|
||||
return new j$.Exactly(sample);
|
||||
j$.is = function(sample) {
|
||||
return new j$.Is(sample);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -2813,24 +2813,6 @@ getJasmineRequireObj().Empty = function(j$) {
|
||||
return Empty;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().Exactly = function(j$) {
|
||||
class Exactly {
|
||||
constructor(expected) {
|
||||
this.expected_ = expected;
|
||||
}
|
||||
|
||||
asymmetricMatch(actual) {
|
||||
return actual === this.expected_;
|
||||
}
|
||||
|
||||
jasmineToString(pp) {
|
||||
return `<jasmine.exactly(${pp(this.expected_)})>`;
|
||||
}
|
||||
}
|
||||
|
||||
return Exactly;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().Falsy = function(j$) {
|
||||
function Falsy() {}
|
||||
|
||||
@@ -2845,6 +2827,24 @@ getJasmineRequireObj().Falsy = function(j$) {
|
||||
return Falsy;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().Is = function(j$) {
|
||||
class Is {
|
||||
constructor(expected) {
|
||||
this.expected_ = expected;
|
||||
}
|
||||
|
||||
asymmetricMatch(actual) {
|
||||
return actual === this.expected_;
|
||||
}
|
||||
|
||||
jasmineToString(pp) {
|
||||
return `<jasmine.is(${pp(this.expected_)})>`;
|
||||
}
|
||||
}
|
||||
|
||||
return Is;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().MapContaining = function(j$) {
|
||||
function MapContaining(sample) {
|
||||
if (!j$.isMap(sample)) {
|
||||
|
||||
@@ -72,8 +72,8 @@ describe('Suite', function() {
|
||||
suite.beforeAll(innerBefore);
|
||||
|
||||
expect(suite.beforeAllFns).toEqual([
|
||||
{ fn: outerBefore.fn, type: 'beforeAll', suite: jasmine.exactly(suite) },
|
||||
{ fn: innerBefore.fn, type: 'beforeAll', suite: jasmine.exactly(suite) }
|
||||
{ fn: outerBefore.fn, type: 'beforeAll', suite: jasmine.is(suite) },
|
||||
{ fn: innerBefore.fn, type: 'beforeAll', suite: jasmine.is(suite) }
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
describe('Exactly', function() {
|
||||
describe('Is', function() {
|
||||
it('passes for primitives that are ===', function() {
|
||||
const exactly = new jasmineUnderTest.Exactly(17);
|
||||
const exactly = new jasmineUnderTest.Is(17);
|
||||
expect(exactly.asymmetricMatch(17)).toBeTrue();
|
||||
});
|
||||
|
||||
it('fails for primitives that are not ===', function() {
|
||||
const exactly = new jasmineUnderTest.Exactly(42);
|
||||
const exactly = new jasmineUnderTest.Is(42);
|
||||
expect(exactly.asymmetricMatch('42')).toBeFalse();
|
||||
});
|
||||
|
||||
it('passes for the same object instance', function() {
|
||||
const obj = {};
|
||||
const exactly = new jasmineUnderTest.Exactly(obj);
|
||||
const exactly = new jasmineUnderTest.Is(obj);
|
||||
expect(exactly.asymmetricMatch(obj)).toBeTrue();
|
||||
});
|
||||
|
||||
it('fails for different object instances, even if they are deep value equal', function() {
|
||||
const exactly = new jasmineUnderTest.Exactly({});
|
||||
const exactly = new jasmineUnderTest.Is({});
|
||||
expect(exactly.asymmetricMatch({})).toBeFalse();
|
||||
});
|
||||
|
||||
it('describes itself for use in diffs and pretty printing', function() {
|
||||
const exactly = new jasmineUnderTest.Exactly({ foo: ['bar'] });
|
||||
const exactly = new jasmineUnderTest.Is({ foo: ['bar'] });
|
||||
const pp = jasmineUnderTest.basicPrettyPrinter_;
|
||||
expect(exactly.jasmineToString(pp)).toEqual(
|
||||
"<jasmine.exactly(Object({ foo: [ 'bar' ] }))>"
|
||||
"<jasmine.is(Object({ foo: [ 'bar' ] }))>"
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().Exactly = function(j$) {
|
||||
class Exactly {
|
||||
getJasmineRequireObj().Is = function(j$) {
|
||||
class Is {
|
||||
constructor(expected) {
|
||||
this.expected_ = expected;
|
||||
}
|
||||
@@ -9,9 +9,9 @@ getJasmineRequireObj().Exactly = function(j$) {
|
||||
}
|
||||
|
||||
jasmineToString(pp) {
|
||||
return `<jasmine.exactly(${pp(this.expected_)})>`;
|
||||
return `<jasmine.is(${pp(this.expected_)})>`;
|
||||
}
|
||||
}
|
||||
|
||||
return Exactly;
|
||||
return Is;
|
||||
};
|
||||
@@ -287,12 +287,12 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
* Get an {@link AsymmetricEqualityTester}, usable in any {@link matchers|matcher}
|
||||
* that passes if the actual value is the same as the sample as determined
|
||||
* by the `===` operator.
|
||||
* @name jasmine.exactly
|
||||
* @name jasmine.is
|
||||
* @function
|
||||
* @param {Object} sample - The value to compare the actual to.
|
||||
*/
|
||||
j$.exactly = function(sample) {
|
||||
return new j$.Exactly(sample);
|
||||
j$.is = function(sample) {
|
||||
return new j$.Is(sample);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,7 +91,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
|
||||
j$.Falsy = jRequire.Falsy(j$);
|
||||
j$.Empty = jRequire.Empty(j$);
|
||||
j$.NotEmpty = jRequire.NotEmpty(j$);
|
||||
j$.Exactly = jRequire.Exactly(j$);
|
||||
j$.Is = jRequire.Is(j$);
|
||||
|
||||
j$.matchers = jRequire.requireMatchers(jRequire, j$);
|
||||
j$.asyncMatchers = jRequire.requireAsyncMatchers(jRequire, j$);
|
||||
|
||||
Reference in New Issue
Block a user