Move private APIs to private namespace

Fixes #2078
This commit is contained in:
Steve Gravrock
2025-09-27 13:21:09 -07:00
parent fbec066837
commit 168ff0a751
183 changed files with 2627 additions and 2459 deletions

View File

@@ -1,73 +1,73 @@
describe('Any', function() {
it('matches a string', function() {
const any = new jasmineUnderTest.Any(String);
const any = new privateUnderTest.Any(String);
expect(any.asymmetricMatch('foo')).toBe(true);
});
it('matches a number', function() {
const any = new jasmineUnderTest.Any(Number);
const any = new privateUnderTest.Any(Number);
expect(any.asymmetricMatch(1)).toBe(true);
});
it('matches a function', function() {
const any = new jasmineUnderTest.Any(Function);
const any = new privateUnderTest.Any(Function);
expect(any.asymmetricMatch(function() {})).toBe(true);
});
it('matches an Object', function() {
const any = new jasmineUnderTest.Any(Object);
const any = new privateUnderTest.Any(Object);
expect(any.asymmetricMatch({})).toBe(true);
});
it('matches a Boolean', function() {
const any = new jasmineUnderTest.Any(Boolean);
const any = new privateUnderTest.Any(Boolean);
expect(any.asymmetricMatch(true)).toBe(true);
});
it('matches a Map', function() {
const any = new jasmineUnderTest.Any(Map);
const any = new privateUnderTest.Any(Map);
expect(any.asymmetricMatch(new Map())).toBe(true);
});
it('matches a Set', function() {
const any = new jasmineUnderTest.Any(Set);
const any = new privateUnderTest.Any(Set);
expect(any.asymmetricMatch(new Set())).toBe(true);
});
it('matches a TypedArray', function() {
const any = new jasmineUnderTest.Any(Uint32Array);
const any = new privateUnderTest.Any(Uint32Array);
expect(any.asymmetricMatch(new Uint32Array([]))).toBe(true);
});
it('matches a Symbol', function() {
const any = new jasmineUnderTest.Any(Symbol);
const any = new privateUnderTest.Any(Symbol);
expect(any.asymmetricMatch(Symbol())).toBe(true);
});
it('matches another constructed object', function() {
const Thing = function() {},
any = new jasmineUnderTest.Any(Thing);
any = new privateUnderTest.Any(Thing);
expect(any.asymmetricMatch(new Thing())).toBe(true);
});
it('does not treat null as an Object', function() {
const any = new jasmineUnderTest.Any(Object);
const any = new privateUnderTest.Any(Object);
expect(any.asymmetricMatch(null)).toBe(false);
});
it("jasmineToString's itself", function() {
const any = new jasmineUnderTest.Any(Number);
const any = new privateUnderTest.Any(Number);
expect(any.jasmineToString()).toEqual('<jasmine.any(Number)>');
expect(any.jasmineToString()).toEqual('<jasmine.any(Number)>');
@@ -76,7 +76,7 @@ describe('Any', function() {
describe('when called without an argument', function() {
it('tells the user to pass a constructor or use jasmine.anything()', function() {
expect(function() {
new jasmineUnderTest.Any();
new privateUnderTest.Any();
}).toThrowError(TypeError, /constructor.*anything/);
});
});

View File

@@ -1,67 +1,67 @@
describe('Anything', function() {
it('matches a string', function() {
const anything = new jasmineUnderTest.Anything();
const anything = new privateUnderTest.Anything();
expect(anything.asymmetricMatch('foo')).toBe(true);
});
it('matches a number', function() {
const anything = new jasmineUnderTest.Anything();
const anything = new privateUnderTest.Anything();
expect(anything.asymmetricMatch(42)).toBe(true);
});
it('matches an object', function() {
const anything = new jasmineUnderTest.Anything();
const anything = new privateUnderTest.Anything();
expect(anything.asymmetricMatch({ foo: 'bar' })).toBe(true);
});
it('matches an array', function() {
const anything = new jasmineUnderTest.Anything();
const anything = new privateUnderTest.Anything();
expect(anything.asymmetricMatch([1, 2, 3])).toBe(true);
});
it('matches a Map', function() {
const anything = new jasmineUnderTest.Anything();
const anything = new privateUnderTest.Anything();
expect(anything.asymmetricMatch(new Map())).toBe(true);
});
it('matches a Set', function() {
const anything = new jasmineUnderTest.Anything();
const anything = new privateUnderTest.Anything();
expect(anything.asymmetricMatch(new Set())).toBe(true);
});
it('matches a TypedArray', function() {
const anything = new jasmineUnderTest.Anything();
const anything = new privateUnderTest.Anything();
expect(anything.asymmetricMatch(new Uint32Array([]))).toBe(true);
});
it('matches a Symbol', function() {
const anything = new jasmineUnderTest.Anything();
const anything = new privateUnderTest.Anything();
expect(anything.asymmetricMatch(Symbol())).toBe(true);
});
it("doesn't match undefined", function() {
const anything = new jasmineUnderTest.Anything();
const anything = new privateUnderTest.Anything();
expect(anything.asymmetricMatch()).toBe(false);
expect(anything.asymmetricMatch(undefined)).toBe(false);
});
it("doesn't match null", function() {
const anything = new jasmineUnderTest.Anything();
const anything = new privateUnderTest.Anything();
expect(anything.asymmetricMatch(null)).toBe(false);
});
it("jasmineToString's itself", function() {
const anything = new jasmineUnderTest.Anything();
const anything = new privateUnderTest.Anything();
expect(anything.jasmineToString()).toEqual('<jasmine.anything>');
});

View File

@@ -1,12 +1,12 @@
describe('ArrayContaining', function() {
it('matches any actual to an empty array', function() {
const containing = new jasmineUnderTest.ArrayContaining([]);
const containing = new privateUnderTest.ArrayContaining([]);
expect(containing.asymmetricMatch('foo')).toBe(true);
});
it('does not work when not passed an array', function() {
const containing = new jasmineUnderTest.ArrayContaining('foo');
const containing = new privateUnderTest.ArrayContaining('foo');
expect(function() {
containing.asymmetricMatch([]);
@@ -14,36 +14,36 @@ describe('ArrayContaining', function() {
});
it('matches when the item is in the actual', function() {
const containing = new jasmineUnderTest.ArrayContaining(['foo']);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.ArrayContaining(['foo']);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(['foo'], matchersUtil)).toBe(true);
});
it('matches when additional items are in the actual', function() {
const containing = new jasmineUnderTest.ArrayContaining(['foo']);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.ArrayContaining(['foo']);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(['foo', 'bar'], matchersUtil)).toBe(true);
});
it('does not match when the item is not in the actual', function() {
const containing = new jasmineUnderTest.ArrayContaining(['foo']);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.ArrayContaining(['foo']);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(['bar'], matchersUtil)).toBe(false);
});
it('does not match when the actual is not an array', function() {
const containing = new jasmineUnderTest.ArrayContaining(['foo']);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.ArrayContaining(['foo']);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch('foo', matchersUtil)).toBe(false);
});
it('jasmineToStrings itself', function() {
const sample = [],
matcher = new jasmineUnderTest.ArrayContaining(sample),
matcher = new privateUnderTest.ArrayContaining(sample),
pp = jasmine.createSpy('pp').and.returnValue('sample');
expect(matcher.jasmineToString(pp)).toEqual(
@@ -64,8 +64,8 @@ describe('ArrayContaining', function() {
return true;
}
};
const containing = new jasmineUnderTest.ArrayContaining(['fooVal']);
const matchersUtil = new jasmineUnderTest.MatchersUtil({
const containing = new privateUnderTest.ArrayContaining(['fooVal']);
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester]
});

View File

@@ -1,13 +1,13 @@
describe('ArrayWithExactContents', function() {
it('matches an array with the same items in a different order', function() {
const matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matcher = new privateUnderTest.ArrayWithExactContents(['a', 2, /a/]);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matcher.asymmetricMatch([2, 'a', /a/], matchersUtil)).toBe(true);
});
it('does not work when not passed an array', function() {
const matcher = new jasmineUnderTest.ArrayWithExactContents('foo');
const matcher = new privateUnderTest.ArrayWithExactContents('foo');
expect(function() {
matcher.asymmetricMatch([]);
@@ -15,8 +15,8 @@ describe('ArrayWithExactContents', function() {
});
it('does not match when an item is missing', function() {
const matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matcher = new privateUnderTest.ArrayWithExactContents(['a', 2, /a/]);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matcher.asymmetricMatch(['a', 2], matchersUtil)).toBe(false);
expect(matcher.asymmetricMatch(['a', 2, undefined], matchersUtil)).toBe(
@@ -25,15 +25,15 @@ describe('ArrayWithExactContents', function() {
});
it('does not match when there is an extra item', function() {
const matcher = new jasmineUnderTest.ArrayWithExactContents(['a']);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matcher = new privateUnderTest.ArrayWithExactContents(['a']);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(matcher.asymmetricMatch(['a', 2], matchersUtil)).toBe(false);
});
it('jasmineToStrings itself', function() {
const sample = [],
matcher = new jasmineUnderTest.ArrayWithExactContents(sample),
matcher = new privateUnderTest.ArrayWithExactContents(sample),
pp = jasmine.createSpy('pp').and.returnValue('sample');
expect(matcher.jasmineToString(pp)).toEqual(
@@ -54,8 +54,8 @@ describe('ArrayWithExactContents', function() {
return true;
}
};
const matcher = new jasmineUnderTest.ArrayWithExactContents(['fooVal']);
const matchersUtil = new jasmineUnderTest.MatchersUtil({
const matcher = new privateUnderTest.ArrayWithExactContents(['fooVal']);
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester]
});

View File

@@ -1,20 +1,20 @@
describe('Empty', function() {
it('matches an empty object', function() {
const empty = new jasmineUnderTest.Empty();
const empty = new privateUnderTest.Empty();
expect(empty.asymmetricMatch({})).toBe(true);
expect(empty.asymmetricMatch({ undefined: false })).toBe(false);
});
it('matches an empty array', function() {
const empty = new jasmineUnderTest.Empty();
const empty = new privateUnderTest.Empty();
expect(empty.asymmetricMatch([])).toBe(true);
expect(empty.asymmetricMatch([1, 12, 3])).toBe(false);
});
it('matches an empty string', function() {
const empty = new jasmineUnderTest.Empty();
const empty = new privateUnderTest.Empty();
expect(empty.asymmetricMatch('')).toBe(true);
expect(empty.asymmetricMatch('')).toBe(true);
@@ -22,7 +22,7 @@ describe('Empty', function() {
});
it('matches an empty map', function() {
const empty = new jasmineUnderTest.Empty();
const empty = new privateUnderTest.Empty();
const fullMap = new Map();
fullMap.set('thing', 2);
@@ -31,7 +31,7 @@ describe('Empty', function() {
});
it('matches an empty set', function() {
const empty = new jasmineUnderTest.Empty();
const empty = new privateUnderTest.Empty();
const fullSet = new Set();
fullSet.add(3);
@@ -40,7 +40,7 @@ describe('Empty', function() {
});
it('matches an empty typed array', function() {
const empty = new jasmineUnderTest.Empty();
const empty = new privateUnderTest.Empty();
expect(empty.asymmetricMatch(new Int16Array())).toBe(true);
expect(empty.asymmetricMatch(new Int16Array([1, 2]))).toBe(false);

View File

@@ -1,6 +1,6 @@
describe('Falsy', function() {
it('is true for an empty string', function() {
const falsy = new jasmineUnderTest.Falsy();
const falsy = new privateUnderTest.Falsy();
expect(falsy.asymmetricMatch('')).toBe(true);
expect(falsy.asymmetricMatch('')).toBe(true);
@@ -8,7 +8,7 @@ describe('Falsy', function() {
});
it('is false for a number that is 0', function() {
const falsy = new jasmineUnderTest.Falsy(Number);
const falsy = new privateUnderTest.Falsy(Number);
expect(falsy.asymmetricMatch(1)).toBe(false);
expect(falsy.asymmetricMatch(0)).toBe(true);
@@ -17,20 +17,20 @@ describe('Falsy', function() {
});
it('is true for a null or undefined', function() {
const falsy = new jasmineUnderTest.Falsy(Function);
const falsy = new privateUnderTest.Falsy(Function);
expect(falsy.asymmetricMatch(null)).toBe(true);
expect(falsy.asymmetricMatch(undefined)).toBe(true);
});
it('is true for NaN', function() {
const falsy = new jasmineUnderTest.Falsy(Object);
const falsy = new privateUnderTest.Falsy(Object);
expect(falsy.asymmetricMatch(NaN)).toBe(true);
});
it('is true for a false Boolean', function() {
const falsy = new jasmineUnderTest.Falsy(Boolean);
const falsy = new privateUnderTest.Falsy(Boolean);
expect(falsy.asymmetricMatch(false)).toBe(true);
expect(falsy.asymmetricMatch(true)).toBe(false);

View File

@@ -1,28 +1,28 @@
describe('Is', function() {
it('passes for primitives that are ===', function() {
const exactly = new jasmineUnderTest.Is(17);
const exactly = new privateUnderTest.Is(17);
expect(exactly.asymmetricMatch(17)).toBeTrue();
});
it('fails for primitives that are not ===', function() {
const exactly = new jasmineUnderTest.Is(42);
const exactly = new privateUnderTest.Is(42);
expect(exactly.asymmetricMatch('42')).toBeFalse();
});
it('passes for the same object instance', function() {
const obj = {};
const exactly = new jasmineUnderTest.Is(obj);
const exactly = new privateUnderTest.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.Is({});
const exactly = new privateUnderTest.Is({});
expect(exactly.asymmetricMatch({})).toBeFalse();
});
it('describes itself for use in diffs and pretty printing', function() {
const exactly = new jasmineUnderTest.Is({ foo: ['bar'] });
const pp = jasmineUnderTest.basicPrettyPrinter_;
const exactly = new privateUnderTest.Is({ foo: ['bar'] });
const pp = privateUnderTest.basicPrettyPrinter;
expect(exactly.jasmineToString(pp)).toEqual(
"<jasmine.is(Object({ foo: [ 'bar' ] }))>"
);

View File

@@ -1,7 +1,7 @@
describe('MapContaining', function() {
it('matches any actual map to an empty map', function() {
const actualMap = new Map([['foo', 'bar']]);
const containing = new jasmineUnderTest.MapContaining(new Map());
const containing = new privateUnderTest.MapContaining(new Map());
expect(containing.asymmetricMatch(actualMap)).toBe(true);
});
@@ -17,8 +17,8 @@ describe('MapContaining', function() {
[{ foo: 'bar' }, 'baz'],
['foo', [1, 2, 3]]
]);
const containing = new jasmineUnderTest.MapContaining(containingMap);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.MapContaining(containingMap);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(true);
});
@@ -33,8 +33,8 @@ describe('MapContaining', function() {
[{ foo: 'bar' }, 'baz'],
['foo', [1, 2, 3]]
]);
const containing = new jasmineUnderTest.MapContaining(containingMap);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.MapContaining(containingMap);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false);
});
@@ -43,8 +43,8 @@ describe('MapContaining', function() {
const actualMap = new Map([['foo', [1, 2, 3]], [{ foo: 'bar' }, 'baz']]);
const containingMap = new Map([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2]]]);
const containing = new jasmineUnderTest.MapContaining(containingMap);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.MapContaining(containingMap);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false);
});
@@ -60,8 +60,8 @@ describe('MapContaining', function() {
[jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
['baz', jasmineUnderTest.arrayContaining([2, 3])]
]);
const containing = new jasmineUnderTest.MapContaining(containingMap);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.MapContaining(containingMap);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(true);
});
@@ -73,8 +73,8 @@ describe('MapContaining', function() {
[jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
['baz', jasmineUnderTest.arrayContaining([2, 3])]
]);
const containing = new jasmineUnderTest.MapContaining(containingMap);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.MapContaining(containingMap);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false);
});
@@ -86,8 +86,8 @@ describe('MapContaining', function() {
[jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
['baz', jasmineUnderTest.arrayContaining([4, 5])]
]);
const containing = new jasmineUnderTest.MapContaining(containingMap);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.MapContaining(containingMap);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false);
});
@@ -100,11 +100,11 @@ describe('MapContaining', function() {
]);
const containingMap = new Map([
['foo', new jasmineUnderTest.MapContaining(new Map([['foo1', 1]]))],
[new jasmineUnderTest.MapContaining(new Map([[2, 'bar2']])), 'bar']
['foo', new privateUnderTest.MapContaining(new Map([['foo1', 1]]))],
[new privateUnderTest.MapContaining(new Map([[2, 'bar2']])), 'bar']
]);
const containing = new jasmineUnderTest.MapContaining(containingMap);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.MapContaining(containingMap);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(true);
});
@@ -117,10 +117,10 @@ describe('MapContaining', function() {
: a === b;
}
const actualMap = new Map([['foo', -1]]);
const containing = new jasmineUnderTest.MapContaining(
const containing = new privateUnderTest.MapContaining(
new Map([['foo', -2]])
);
const matchersUtil = new jasmineUnderTest.MatchersUtil({
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester]
});
@@ -130,13 +130,13 @@ describe('MapContaining', function() {
it('does not match when actual is not a map', function() {
const containingMap = new Map([['foo', 'bar']]);
expect(
new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch('foo')
new privateUnderTest.MapContaining(containingMap).asymmetricMatch('foo')
).toBe(false);
expect(
new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch(-1)
new privateUnderTest.MapContaining(containingMap).asymmetricMatch(-1)
).toBe(false);
expect(
new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch({
new privateUnderTest.MapContaining(containingMap).asymmetricMatch({
foo: 'bar'
})
).toBe(false);
@@ -144,7 +144,7 @@ describe('MapContaining', function() {
it('throws an error when sample is not a map', function() {
expect(function() {
new jasmineUnderTest.MapContaining({ foo: 'bar' }).asymmetricMatch(
new privateUnderTest.MapContaining({ foo: 'bar' }).asymmetricMatch(
new Map()
);
}).toThrowError(/You must provide a map/);
@@ -152,7 +152,7 @@ describe('MapContaining', function() {
it('defines a `jasmineToString` method', function() {
const sample = new Map(),
containing = new jasmineUnderTest.MapContaining(sample),
containing = new privateUnderTest.MapContaining(sample),
pp = jasmine.createSpy('pp').and.returnValue('sample');
expect(containing.jasmineToString(pp)).toEqual(

View File

@@ -1,20 +1,20 @@
describe('NotEmpty', function() {
it('matches a non empty object', function() {
const notEmpty = new jasmineUnderTest.NotEmpty();
const notEmpty = new privateUnderTest.NotEmpty();
expect(notEmpty.asymmetricMatch({ undefined: false })).toBe(true);
expect(notEmpty.asymmetricMatch({})).toBe(false);
});
it('matches a non empty array', function() {
const notEmpty = new jasmineUnderTest.NotEmpty();
const notEmpty = new privateUnderTest.NotEmpty();
expect(notEmpty.asymmetricMatch([1, 12, 3])).toBe(true);
expect(notEmpty.asymmetricMatch([])).toBe(false);
});
it('matches a non empty string', function() {
const notEmpty = new jasmineUnderTest.NotEmpty();
const notEmpty = new privateUnderTest.NotEmpty();
expect(notEmpty.asymmetricMatch('12312')).toBe(true);
expect(notEmpty.asymmetricMatch('')).toBe(false);
@@ -22,7 +22,7 @@ describe('NotEmpty', function() {
});
it('matches a non empty map', function() {
const notEmpty = new jasmineUnderTest.NotEmpty();
const notEmpty = new privateUnderTest.NotEmpty();
const fullMap = new Map();
fullMap.set('one', 1);
const emptyMap = new Map();
@@ -32,7 +32,7 @@ describe('NotEmpty', function() {
});
it('matches a non empty set', function() {
const notEmpty = new jasmineUnderTest.NotEmpty();
const notEmpty = new privateUnderTest.NotEmpty();
const filledSet = new Set();
filledSet.add(1);
const emptySet = new Set();
@@ -42,7 +42,7 @@ describe('NotEmpty', function() {
});
it('matches a non empty typed array', function() {
const notEmpty = new jasmineUnderTest.NotEmpty();
const notEmpty = new privateUnderTest.NotEmpty();
expect(notEmpty.asymmetricMatch(new Int16Array([1, 2, 3]))).toBe(true);
expect(notEmpty.asymmetricMatch(new Int16Array())).toBe(false);

View File

@@ -1,13 +1,13 @@
describe('ObjectContaining', function() {
it('matches any object actual to an empty object', function() {
const containing = new jasmineUnderTest.ObjectContaining({});
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.ObjectContaining({});
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch({ foo: 1 }, matchersUtil)).toBe(true);
});
it('does not match when the actual is not an object', function() {
const containing = new jasmineUnderTest.ObjectContaining({});
const containing = new privateUnderTest.ObjectContaining({});
[1, true, undefined, 'a string'].forEach(function(actual) {
expect(containing.asymmetricMatch(actual)).toBe(false);
@@ -15,7 +15,7 @@ describe('ObjectContaining', function() {
});
it('does not match an empty object actual', function() {
const containing = new jasmineUnderTest.ObjectContaining('foo');
const containing = new privateUnderTest.ObjectContaining('foo');
expect(function() {
containing.asymmetricMatch({});
@@ -23,8 +23,8 @@ describe('ObjectContaining', function() {
});
it('matches when the key/value pair is present in the actual', function() {
const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' });
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(
containing.asymmetricMatch({ foo: 'fooVal', bar: 'barVal' }, matchersUtil)
@@ -32,8 +32,8 @@ describe('ObjectContaining', function() {
});
it('does not match when the key/value pair is not present in the actual', function() {
const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' });
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(
containing.asymmetricMatch(
@@ -44,8 +44,8 @@ describe('ObjectContaining', function() {
});
it('does not match when the key is present but the value is different in the actual', function() {
const containing = new jasmineUnderTest.ObjectContaining({ foo: 'other' });
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.ObjectContaining({ foo: 'other' });
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(
containing.asymmetricMatch({ foo: 'fooVal', bar: 'barVal' }, matchersUtil)
@@ -54,7 +54,7 @@ describe('ObjectContaining', function() {
it("jasmineToString's itself", function() {
const sample = {},
matcher = new jasmineUnderTest.ObjectContaining(sample),
matcher = new privateUnderTest.ObjectContaining(sample),
pp = jasmine.createSpy('pp').and.returnValue('sample');
expect(matcher.jasmineToString(pp)).toEqual(
@@ -64,10 +64,10 @@ describe('ObjectContaining', function() {
});
it('matches recursively', function() {
const containing = new jasmineUnderTest.ObjectContaining({
one: new jasmineUnderTest.ObjectContaining({ two: {} })
const containing = new privateUnderTest.ObjectContaining({
one: new privateUnderTest.ObjectContaining({ two: {} })
});
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch({ one: { two: {} } }, matchersUtil)).toBe(
true
@@ -75,10 +75,10 @@ describe('ObjectContaining', function() {
});
it('matches when key is present with undefined value', function() {
const containing = new jasmineUnderTest.ObjectContaining({
const containing = new privateUnderTest.ObjectContaining({
one: undefined
});
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch({ one: undefined }, matchersUtil)).toBe(
true
@@ -86,17 +86,17 @@ describe('ObjectContaining', function() {
});
it('does not match when key with undefined value is not present', function() {
const containing = new jasmineUnderTest.ObjectContaining({
const containing = new privateUnderTest.ObjectContaining({
one: undefined
});
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch({}, matchersUtil)).toBe(false);
});
it('matches defined properties', function() {
const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' });
const matchersUtil = new privateUnderTest.MatchersUtil();
const definedPropertyObject = {};
Object.defineProperty(definedPropertyObject, 'foo', {
@@ -110,8 +110,8 @@ describe('ObjectContaining', function() {
});
it('matches prototype properties', function() {
const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' });
const matchersUtil = new privateUnderTest.MatchersUtil();
const prototypeObject = { foo: 'fooVal' };
const obj = Object.create(prototypeObject);
@@ -131,8 +131,8 @@ describe('ObjectContaining', function() {
return true;
}
};
const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
const matchersUtil = new jasmineUnderTest.MatchersUtil({
const containing = new privateUnderTest.ObjectContaining({ foo: 'fooVal' });
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester]
});
@@ -144,8 +144,8 @@ describe('ObjectContaining', function() {
describe('valuesForDiff_', function() {
describe('when other is not an object', function() {
it('sets self to jasmineToString()', function() {
const containing = new jasmineUnderTest.ObjectContaining({}),
pp = jasmineUnderTest.makePrettyPrinter(),
const containing = new privateUnderTest.ObjectContaining({}),
pp = privateUnderTest.makePrettyPrinter(),
result = containing.valuesForDiff_('a', pp);
expect(result).toEqual({
@@ -159,11 +159,11 @@ describe('ObjectContaining', function() {
it('includes keys that are present in both other and sample', function() {
const sample = { a: 1, b: 2 },
other = { a: 3, b: 4 },
containing = new jasmineUnderTest.ObjectContaining(sample),
containing = new privateUnderTest.ObjectContaining(sample),
result = containing.valuesForDiff_(other);
expect(result.self).not.toBeInstanceOf(
jasmineUnderTest.ObjectContaining
privateUnderTest.ObjectContaining
);
expect(result).toEqual({
self: sample,
@@ -174,11 +174,11 @@ describe('ObjectContaining', function() {
it('includes keys that are present only in sample', function() {
const sample = { a: 1, b: 2 },
other = { a: 3 },
containing = new jasmineUnderTest.ObjectContaining(sample),
containing = new privateUnderTest.ObjectContaining(sample),
result = containing.valuesForDiff_(other);
expect(result.self).not.toBeInstanceOf(
jasmineUnderTest.ObjectContaining
privateUnderTest.ObjectContaining
);
expect(containing.valuesForDiff_(other)).toEqual({
self: sample,
@@ -192,11 +192,11 @@ describe('ObjectContaining', function() {
it('omits keys that are present only in other', function() {
const sample = { a: 1, b: 2 },
other = { a: 3, b: 4, c: 5 },
containing = new jasmineUnderTest.ObjectContaining(sample),
containing = new privateUnderTest.ObjectContaining(sample),
result = containing.valuesForDiff_(other);
expect(result.self).not.toBeInstanceOf(
jasmineUnderTest.ObjectContaining
privateUnderTest.ObjectContaining
);
expect(result).toEqual({
self: sample,

View File

@@ -1,7 +1,7 @@
describe('SetContaining', function() {
it('matches any actual set to an empty set', function() {
const actualSet = new Set(['foo', 'bar']);
const containing = new jasmineUnderTest.SetContaining(new Set());
const containing = new privateUnderTest.SetContaining(new Set());
expect(containing.asymmetricMatch(actualSet)).toBe(true);
});
@@ -10,8 +10,8 @@ describe('SetContaining', function() {
const actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]);
const containingSet = new Set([[1, 2, 3], { foo: 'bar' }]);
const containing = new jasmineUnderTest.SetContaining(containingSet);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.SetContaining(containingSet);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(true);
});
@@ -20,8 +20,8 @@ describe('SetContaining', function() {
const actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]);
const containingSet = new Set([[1, 2], { foo: 'bar' }]);
const containing = new jasmineUnderTest.SetContaining(containingSet);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.SetContaining(containingSet);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(false);
});
@@ -33,8 +33,8 @@ describe('SetContaining', function() {
jasmineUnderTest.stringMatching(/^foo\d/),
jasmineUnderTest.arrayContaining([2, 3])
]);
const containing = new jasmineUnderTest.SetContaining(containingSet);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.SetContaining(containingSet);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(true);
});
@@ -46,8 +46,8 @@ describe('SetContaining', function() {
jasmine.stringMatching(/^foo\d/),
jasmine.arrayContaining([2, 3])
]);
const containing = new jasmineUnderTest.SetContaining(containingSet);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.SetContaining(containingSet);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(false);
});
@@ -56,11 +56,11 @@ describe('SetContaining', function() {
const actualSet = new Set(['foo', new Set([1, 'bar', 2]), 'other']);
const containingSet = new Set([
new jasmineUnderTest.SetContaining(new Set(['bar'])),
new privateUnderTest.SetContaining(new Set(['bar'])),
'foo'
]);
const containing = new jasmineUnderTest.SetContaining(containingSet);
const matchersUtil = new jasmineUnderTest.MatchersUtil();
const containing = new privateUnderTest.SetContaining(containingSet);
const matchersUtil = new privateUnderTest.MatchersUtil();
expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(true);
});
@@ -73,8 +73,8 @@ describe('SetContaining', function() {
: a === b;
}
const actualSet = new Set(['foo', -1]);
const containing = new jasmineUnderTest.SetContaining(new Set([-2, 'foo']));
const matchersUtil = new jasmineUnderTest.MatchersUtil({
const containing = new privateUnderTest.SetContaining(new Set([-2, 'foo']));
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: [tester]
});
@@ -84,19 +84,19 @@ describe('SetContaining', function() {
it('does not match when actual is not a set', function() {
const containingSet = new Set(['foo']);
expect(
new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch('foo')
new privateUnderTest.SetContaining(containingSet).asymmetricMatch('foo')
).toBe(false);
expect(
new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch(1)
new privateUnderTest.SetContaining(containingSet).asymmetricMatch(1)
).toBe(false);
expect(
new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch(['foo'])
new privateUnderTest.SetContaining(containingSet).asymmetricMatch(['foo'])
).toBe(false);
});
it('throws an error when sample is not a set', function() {
expect(function() {
new jasmineUnderTest.SetContaining({ foo: 'bar' }).asymmetricMatch(
new privateUnderTest.SetContaining({ foo: 'bar' }).asymmetricMatch(
new Set()
);
}).toThrowError(/You must provide a set/);
@@ -104,7 +104,7 @@ describe('SetContaining', function() {
it('defines a `jasmineToString` method', function() {
const sample = new Set(),
containing = new jasmineUnderTest.SetContaining(sample),
containing = new privateUnderTest.SetContaining(sample),
pp = jasmine.createSpy('pp').and.returnValue('sample');
expect(containing.jasmineToString(pp)).toEqual(

View File

@@ -1,6 +1,6 @@
describe('StringContaining', function() {
it('searches for a provided substring when the expected is a String', function() {
const matcher = new jasmineUnderTest.StringContaining('foo');
const matcher = new privateUnderTest.StringContaining('foo');
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
@@ -8,17 +8,17 @@ describe('StringContaining', function() {
it('raises an Error when the expected is not a String', function() {
expect(function() {
new jasmineUnderTest.StringContaining(/foo/);
new privateUnderTest.StringContaining(/foo/);
}).toThrowError(/not a String/);
});
it('fails when the actual is not a String', function() {
const matcher = new jasmineUnderTest.StringContaining('x');
const matcher = new privateUnderTest.StringContaining('x');
expect(matcher.asymmetricMatch(['x'])).toBe(false);
});
it("jasmineToString's itself", function() {
const matching = new jasmineUnderTest.StringContaining('foo');
const matching = new privateUnderTest.StringContaining('foo');
expect(matching.jasmineToString()).toEqual(
'<jasmine.stringContaining("foo")>'

View File

@@ -1,13 +1,13 @@
describe('StringMatching', function() {
it('matches a string against a provided regexp', function() {
const matcher = new jasmineUnderTest.StringMatching(/foo/);
const matcher = new privateUnderTest.StringMatching(/foo/);
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
});
it('matches a string against provided string', function() {
const matcher = new jasmineUnderTest.StringMatching('foo');
const matcher = new privateUnderTest.StringMatching('foo');
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
@@ -15,12 +15,12 @@ describe('StringMatching', function() {
it('raises an Error when the expected is not a String or RegExp', function() {
expect(function() {
new jasmineUnderTest.StringMatching({});
new privateUnderTest.StringMatching({});
}).toThrowError(/not a String or a RegExp/);
});
it("jasmineToString's itself", function() {
const matching = new jasmineUnderTest.StringMatching(/^foo/);
const matching = new privateUnderTest.StringMatching(/^foo/);
expect(matching.jasmineToString()).toEqual(
'<jasmine.stringMatching(/^foo/)>'

View File

@@ -1,13 +1,13 @@
describe('Truthy', function() {
it('is true for a non empty string', function() {
const truthy = new jasmineUnderTest.Truthy();
const truthy = new privateUnderTest.Truthy();
expect(truthy.asymmetricMatch('foo')).toBe(true);
expect(truthy.asymmetricMatch('')).toBe(false);
});
it('is true for a number that is not 0', function() {
const truthy = new jasmineUnderTest.Truthy();
const truthy = new privateUnderTest.Truthy();
expect(truthy.asymmetricMatch(1)).toBe(true);
expect(truthy.asymmetricMatch(0)).toBe(false);
@@ -16,44 +16,44 @@ describe('Truthy', function() {
});
it('is true for a function', function() {
const truthy = new jasmineUnderTest.Truthy();
const truthy = new privateUnderTest.Truthy();
expect(truthy.asymmetricMatch(function() {})).toBe(true);
});
it('is true for an Object', function() {
const truthy = new jasmineUnderTest.Truthy();
const truthy = new privateUnderTest.Truthy();
expect(truthy.asymmetricMatch({})).toBe(true);
});
it('is true for a truthful Boolean', function() {
const truthy = new jasmineUnderTest.Truthy();
const truthy = new privateUnderTest.Truthy();
expect(truthy.asymmetricMatch(true)).toBe(true);
expect(truthy.asymmetricMatch(false)).toBe(false);
});
it('is true for an empty object', function() {
const truthy = new jasmineUnderTest.Truthy();
const truthy = new privateUnderTest.Truthy();
expect(truthy.asymmetricMatch({})).toBe(true);
});
it('is true for an empty array', function() {
const truthy = new jasmineUnderTest.Truthy();
const truthy = new privateUnderTest.Truthy();
expect(truthy.asymmetricMatch([])).toBe(true);
});
it('is true for a date', function() {
const truthy = new jasmineUnderTest.Truthy();
const truthy = new privateUnderTest.Truthy();
expect(truthy.asymmetricMatch(new Date())).toBe(true);
});
it('is true for a infiniti', function() {
const truthy = new jasmineUnderTest.Truthy();
const truthy = new privateUnderTest.Truthy();
expect(truthy.asymmetricMatch(Infinity)).toBe(true);
expect(truthy.asymmetricMatch(-Infinity)).toBe(true);