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