level_0
int64 6
10k
| index
int64 0
0
| repo_id
stringlengths 16
148
| file_path
stringlengths 33
188
| content
stringlengths 17
26.8M
|
---|---|---|---|---|
5,612 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-be-visible-string.ts | /// <reference types="jasmine" />
import { isVisibleString } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a valid `String` containing at least one character which is not whitespace.
* @example
* expect('i am visible').toBeVisibleString();
*/
toBeVisibleString(): boolean;
}
}
}
export const toBeVisibleStringMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown) {
const pass = isVisibleString(value);
const message = pass
? `expected ${printReceived(
value,
)} not to be a string with at least one non-whitespace character`
: `expected ${printReceived(
value,
)} to be a string with at least one non-whitespace character`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toBeVisibleString: toBeVisibleStringMatcher,
});
});
|
5,613 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-be-walkable.ts | /// <reference types="jasmine" />
import { isWalkable } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is safe to attempt to read property values from.
* @example
* expect({}).toBeWalkable();
*/
toBeWalkable(): boolean;
}
}
}
export const toBeWalkableMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown) {
const pass = isWalkable(value);
const message = pass
? `expected ${printReceived(value)} not to be walkable`
: `expected ${printReceived(value)} to be walkable`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toBeWalkable: toBeWalkableMatcher,
});
});
|
5,614 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-be-whitespace.ts | /// <reference types="jasmine" />
import { isWhitespace } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `String` containing only whitespace characters.
* @example
* expect(' ').toBeWhitespace();
*/
toBeWhitespace(): boolean;
}
}
}
export const toBeWhitespaceMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown) {
const pass = isWhitespace(value);
const message = pass
? `expected ${printReceived(
value,
)} not to be a string containing only whitespace characters`
: `expected ${printReceived(value)} to be a string containing only whitespace characters`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toBeWhitespace: toBeWhitespaceMatcher,
});
});
|
5,615 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-be-whole-number.ts | /// <reference types="jasmine" />
import { isWholeNumber } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `Number` with no positive decimal places.
* @example
* expect(8).toBeWholeNumber();
*/
toBeWholeNumber(): boolean;
}
}
}
export const toBeWholeNumberMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown) {
const pass = isWholeNumber(value);
const message = pass
? `expected ${printReceived(value)} not to be a whole number`
: `expected ${printReceived(value)} to be a whole number`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toBeWholeNumber: toBeWholeNumberMatcher,
});
});
|
5,616 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-be-within-range.ts | /// <reference types="jasmine" />
import { isWithinRange } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `Number` which is both greater than or equal to `floor` and less than or equal to `ceiling`.
* @example
* expect(7).toBeWithinRange(0, 10);
*/
toBeWithinRange(floor: number, ceiling: number): boolean;
}
}
}
export const toBeWithinRangeMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, floor: number, ceiling: number) {
const pass = isWithinRange(floor, ceiling, value);
const message = pass
? `expected ${printReceived(value)} not to be greater than or equal to ${printExpected(
floor,
)} and less than or equal to ${printExpected(ceiling)}`
: `expected ${printReceived(value)} to be greater than or equal to ${printExpected(
floor,
)} and less than or equal to ${printExpected(ceiling)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toBeWithinRange: toBeWithinRangeMatcher,
});
});
|
5,617 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-end-with.ts | /// <reference types="jasmine" />
import { endsWith } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that value is a string whose trailing characters are equal to those of the provided string.
* @example
* expect('JavaScript').toEndWith('Script');
*/
toEndWith(otherString: unknown): boolean;
}
}
}
export const toEndWithMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, otherString: unknown) {
const pass = endsWith(otherString, value);
const message = pass
? `expected ${printReceived(value)} not to end with ${printExpected(otherString)}`
: `expected ${printReceived(value)} to end with ${printExpected(otherString)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toEndWith: toEndWithMatcher,
});
});
|
5,618 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-array-including-all-of.ts | import { isArrayIncludingAllOf } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that `value` is an `Array` including all of the values provided in `requiredValues`. It could also include additional values or be in a different order, but if every value in `requiredValues` features in `value` then this will return `true`.
* @example
* expect({ child: { grandchild: [12, 0, 14, 'Ivo'] } }).toHaveArrayIncludingAllOf('child.grandchild', ['Ivo', 14]);
*/
toHaveArrayIncludingAllOf(propPath: string, requiredValues: unknown[]): boolean;
}
}
}
export const toHaveArrayIncludingAllOfMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, requiredValues: unknown[]) {
const pass = isArrayIncludingAllOf(requiredValues, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to include every value provided in ${printExpected(requiredValues)}`
: `expected value at '${printExpected(
propPath,
)}' to include every value provided in ${printExpected(requiredValues)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveArrayIncludingAllOf: toHaveArrayIncludingAllOfMatcher,
});
});
|
5,619 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-array-including-any-of.ts | import { isArrayIncludingAnyOf } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that `value` is an `Array` including at least one of the members of `allowedValues`.
* @example
* expect({ child: { grandchild: [12, 0, 14, 'Ginola'] } }).toHaveArrayIncludingAnyOf('child.grandchild', ['Ginola', 3]);
*/
toHaveArrayIncludingAnyOf(propPath: string, allowedValues: unknown[]): boolean;
}
}
}
export const toHaveArrayIncludingAnyOfMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, allowedValues: unknown[]) {
const pass = isArrayIncludingAnyOf(allowedValues, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to include at least one of the values in ${printExpected(allowedValues)}`
: `expected value at '${printExpected(
propPath,
)}' to include at least one of the values in ${printExpected(allowedValues)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveArrayIncludingAnyOf: toHaveArrayIncludingAnyOfMatcher,
});
});
|
5,620 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-array-including-only.ts | import { isArrayIncludingOnly } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an `Array` including only the values provided in the given `allowedValues` array and no others. The order and number of times each value appears in either array does not matter. Returns true unless `value` contains a value which does not feature in `allowedValues`.
* @example
* expect({ child: { grandchild: [5, 10, 1] } }).toHaveArrayIncludingOnly('child.grandchild', [1, 5, 10]);
*/
toHaveArrayIncludingOnly(propPath: string, allowedValues: unknown[]): boolean;
}
}
}
export const toHaveArrayIncludingOnlyMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, allowedValues: unknown[]) {
const pass = isArrayIncludingOnly(allowedValues, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to only include values featured in ${printExpected(allowedValues)} and no others`
: `expected value at '${printExpected(
propPath,
)}' to only include values featured in ${printExpected(allowedValues)} and no others`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveArrayIncludingOnly: toHaveArrayIncludingOnlyMatcher,
});
});
|
5,621 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-array-of-booleans.ts | import { isArrayOfBooleans } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an `Array` containing only `Boolean` values.
* @example
* expect({ child: { grandchild: [true, false, new Boolean(true)] } }).toHaveArrayOfBooleans('child.grandchild');
*/
toHaveArrayOfBooleans(propPath: string): boolean;
}
}
}
export const toHaveArrayOfBooleansMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isArrayOfBooleans(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be a non-empty array, containing only boolean values`
: `expected value at '${printExpected(
propPath,
)}' to be a non-empty array, containing only boolean values`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveArrayOfBooleans: toHaveArrayOfBooleansMatcher,
});
});
|
5,622 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-array-of-numbers.ts | import { isArrayOfNumbers } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an `Array` containing only `Number` values.
* @example
* expect({ child: { grandchild: [12, 0, 14] } }).toHaveArrayOfNumbers('child.grandchild');
*/
toHaveArrayOfNumbers(propPath: string): boolean;
}
}
}
export const toHaveArrayOfNumbersMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isArrayOfNumbers(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be a non-empty array, containing only numbers`
: `expected value at '${printExpected(
propPath,
)}' to be a non-empty array, containing only numbers`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveArrayOfNumbers: toHaveArrayOfNumbersMatcher,
});
});
|
5,623 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-array-of-objects.ts | import { isArrayOfObjects } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an `Array` containing only `Object` values.
* @example
* expect({ child: { grandchild: [{}, new Object()] } }).toHaveArrayOfObjects('child.grandchild');
*/
toHaveArrayOfObjects(propPath: string): boolean;
}
}
}
export const toHaveArrayOfObjectsMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isArrayOfObjects(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be a non-empty array, containing only objects`
: `expected value at '${printExpected(
propPath,
)}' to be a non-empty array, containing only objects`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveArrayOfObjects: toHaveArrayOfObjectsMatcher,
});
});
|
5,624 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-array-of-size.ts | import { isArrayOfSize } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an `Array` containing a specific number of values.
* @example
* expect({ child: { grandchild: ['i', 'contain', 4, 'items'] } }).toHaveArrayOfSize('child.grandchild', 4);
*/
toHaveArrayOfSize(propPath: string, size: number): boolean;
}
}
}
export const toHaveArrayOfSizeMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, size: number) {
const pass = isArrayOfSize(size, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be an array containing exactly ${printExpected(size)} items`
: `expected value at '${printExpected(
propPath,
)}' to be an array containing exactly ${printExpected(size)} items`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveArrayOfSize: toHaveArrayOfSizeMatcher,
});
});
|
5,625 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-array-of-strings.ts | import { isArrayOfStrings } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an `Array` containing only `String` values.
* @example
* expect({ child: { grandchild: ['we', 'are', 'all', 'strings'] } }).toHaveArrayOfStrings('child.grandchild');
*/
toHaveArrayOfStrings(propPath: string): boolean;
}
}
}
export const toHaveArrayOfStringsMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isArrayOfStrings(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be a non-empty array, containing only strings`
: `expected value at '${printExpected(
propPath,
)}' to be a non-empty array, containing only strings`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveArrayOfStrings: toHaveArrayOfStringsMatcher,
});
});
|
5,626 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-array.ts | import { isArray } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a valid `Array` containing none or any number of items of any type.
* @example
* expect({ child: { grandchild: [2, true, 'string'] } }).toHaveArray('child.grandchild');
*/
toHaveArray(propPath: string): boolean;
}
}
}
export const toHaveArrayMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isArray(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be an array`
: `expected value at '${printExpected(propPath)}' to be an array`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveArray: toHaveArrayMatcher,
});
});
|
5,627 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-async-function.ts | import { isAsyncFunction } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a function using `async` and `await` syntax.
* @example
* expect({ child: { grandchild: async () => { await fetch('...') } } }).toHaveAsyncFunction('child.grandchild');
*/
toHaveAsyncFunction(propPath: string): boolean;
}
}
}
export const toHaveAsyncFunctionMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isAsyncFunction(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be a function using async/await syntax`
: `expected value at '${printExpected(
propPath,
)}' to be a \`Function\` using async/await syntax`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveAsyncFunction: toHaveAsyncFunctionMatcher,
});
});
|
5,628 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-boolean.ts | import { isBoolean } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is `true`, `false`, `new Boolean(true)`, or `new Boolean(false)`.
* @example
* expect({ child: { grandchild: false } }).toHaveBoolean('child.grandchild');
*/
toHaveBoolean(propPath: string): boolean;
}
}
}
export const toHaveBooleanMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isBoolean(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be true, false, or an instance of Boolean`
: `expected value at '${printExpected(
propPath,
)}' to be true, false, or an instance of Boolean`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveBoolean: toHaveBooleanMatcher,
});
});
|
5,629 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-calculable.ts | import { isCalculable } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Assert value can be used in Mathemetic calculations despite not being a `Number`, for example `'1' * '2' === 2` whereas `'wut?' * 2 === NaN`.
* @example
* expect({ child: { grandchild: '100' } }).toHaveCalculable('child.grandchild');
*/
toHaveCalculable(propPath: string): boolean;
}
}
}
export const toHaveCalculableMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isCalculable(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be coercible for use in mathemetical operations`
: `expected value at '${printExpected(
propPath,
)}' to be coercible for use in mathemetical operations`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveCalculable: toHaveCalculableMatcher,
});
});
|
5,630 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-date-after.ts | import { isAfter } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a valid instance of `Date` whose value occurs after that of another.
* @example
* expect({ child: { grandchild: new Date('2020-01-01') } }).toHaveDateAfter('child.grandchild', new Date('2019-12-31'));
*/
toHaveDateAfter(propPath: string, otherDate: Date): boolean;
}
}
}
export const toHaveDateAfterMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, otherDate: Date) {
const pass = isAfter(otherDate, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be an instance of Date, occurring after ${printExpected(otherDate)}`
: `expected value at '${printExpected(
propPath,
)}' to be an instance of Date, occurring after ${printExpected(otherDate)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveDateAfter: toHaveDateAfterMatcher,
});
});
|
5,631 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-date-before.ts | import { isBefore } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a valid instance of `Date` whose value occurs before that of another.
* @example
* expect({ child: { grandchild: new Date('2019-12-31') } }).toHaveDateBefore('child.grandchild', new Date('2020-01-01'));
*/
toHaveDateBefore(propPath: string, other: Date): boolean;
}
}
}
export const toHaveDateBeforeMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, other: Date) {
const pass = isBefore(other, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be an instance of Date, occurring before ${printExpected(other)}`
: `expected value at '${printExpected(
propPath,
)}' to be an instance of Date, occurring before ${printExpected(other)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveDateBefore: toHaveDateBeforeMatcher,
});
});
|
5,632 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-date-between.ts | import { isDateBetween } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an instance of `Date` occurring on or after `floor` and on or before `ceiling`.
* @example
* expect({ child: { grandchild: new Date('2019-12-11') } }).toHaveDateBetween('child.grandchild', new Date('2019-12-10'), new Date('2019-12-12'));
*/
toHaveDateBetween(propPath: string, floor: unknown, ceiling: unknown): boolean;
}
}
}
export const toHaveDateBetweenMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, floor: unknown, ceiling: unknown) {
const pass = isDateBetween(floor, ceiling, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be an instance of Date occurring on or after ${printExpected(
floor,
)} and on or before ${printExpected(ceiling)}`
: `expected value at '${printExpected(
propPath,
)}' to be an instance of Date occurring on or after ${printExpected(
floor,
)} and on or before ${printExpected(ceiling)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveDateBetween: toHaveDateBetweenMatcher,
});
});
|
5,633 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-date-in-month.ts | import { isDateInMonth } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an instance of `Date` occurring on the given month of the year, where January is `0` and December is `11`.
* @example
* expect({ child: { grandchild: new Date('2021-08-29') } }).toHaveDateInMonth('child.grandchild', 7);
*/
toHaveDateInMonth(propPath: string, index: number): boolean;
}
}
}
export const toHaveDateInMonthMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, index: number) {
const pass = isDateInMonth(index, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be an instance of Date occurring on the month of the year with index ${printExpected(
index,
)}`
: `expected value at '${printExpected(
propPath,
)}' to be an instance of Date occurring on the month of the year with index ${printExpected(
index,
)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveDateInMonth: toHaveDateInMonthMatcher,
});
});
|
5,634 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-date-in-year.ts | import { isDateInYear } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an instance of `Date` occurring in the given year.
* @example
* expect({ child: { grandchild: new Date('2021-08-29') } }).toHaveDateInYear('child.grandchild', 2021);
*/
toHaveDateInYear(propPath: string, year: number): boolean;
}
}
}
export const toHaveDateInYearMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, year: number) {
const pass = isDateInYear(year, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be an instance of Date occurring in the year ${printExpected(year)}`
: `expected value at '${printExpected(
propPath,
)}' to be an instance of Date occurring in the year ${printExpected(year)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveDateInYear: toHaveDateInYearMatcher,
});
});
|
5,635 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-date-on-day-of-month.ts | import { isDateOnDayOfMonth } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an instance of `Date` occurring on the given day of the month, where the first day of the month is `1` and last is `31`.
* @example
* expect({ child: { grandchild: new Date('2021-08-29') } }).toHaveDateOnDayOfMonth('child.grandchild', 29);
*/
toHaveDateOnDayOfMonth(propPath: string, dayOfMonth: number): boolean;
}
}
}
export const toHaveDateOnDayOfMonthMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, dayOfMonth: number) {
const pass = isDateOnDayOfMonth(dayOfMonth, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be an instance of Date occurring on the ${printExpected(
dayOfMonth,
)} day of the month`
: `expected value at '${printExpected(
propPath,
)}' to be an instance of Date occurring on the ${printExpected(
dayOfMonth,
)} day of the month`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveDateOnDayOfMonth: toHaveDateOnDayOfMonthMatcher,
});
});
|
5,636 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-date-on-day-of-week.ts | import { isDateOnDayOfWeek } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an instance of `Date` occurring on the day of the week with the given index, where Sunday is `0` and Saturday is `6`.
* @example
* expect({ child: { grandchild: new Date('2021-08-29') } }).toHaveDateOnDayOfWeek('child.grandchild', 0);
*/
toHaveDateOnDayOfWeek(propPath: string, index: number): boolean;
}
}
}
export const toHaveDateOnDayOfWeekMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, index: number) {
const pass = isDateOnDayOfWeek(index, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be an instance of Date occurring on the day of the week with index ${printExpected(
index,
)}`
: `expected value at '${printExpected(
propPath,
)}' to be an instance of Date occurring on the day of the week with index ${printExpected(
index,
)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveDateOnDayOfWeek: toHaveDateOnDayOfWeekMatcher,
});
});
|
5,637 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-date-on-or-after.ts | import { isDateOnOrAfter } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an instance of `Date` occurring on or after the exact date and time of another.
* @example
* expect({ child: { grandchild: new Date('2019-12-31') } }).toHaveDateOnOrAfter('child.grandchild', new Date('2019-12-15'));
*/
toHaveDateOnOrAfter(propPath: string, other: unknown): boolean;
}
}
}
export const toHaveDateOnOrAfterMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, other: unknown) {
const pass = isDateOnOrAfter(other, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be an instance of Date occurring on or after ${printExpected(other)}`
: `expected value at '${printExpected(
propPath,
)}' to be an instance of Date occurring on or after ${printExpected(other)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveDateOnOrAfter: toHaveDateOnOrAfterMatcher,
});
});
|
5,638 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-date-on-or-before.ts | import { isDateOnOrBefore } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an instance of `Date` occurring on or before the exact date and time of another.
* @example
* expect({ child: { grandchild: new Date('2019-12-15') } }).toHaveDateOnOrBefore('child.grandchild', new Date('2019-12-31'));
*/
toHaveDateOnOrBefore(propPath: string, other: unknown): boolean;
}
}
}
export const toHaveDateOnOrBeforeMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, other: unknown) {
const pass = isDateOnOrBefore(other, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be an instance of Date occurring on or before ${printExpected(other)}`
: `expected value at '${printExpected(
propPath,
)}' to be an instance of Date occurring on or before ${printExpected(other)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveDateOnOrBefore: toHaveDateOnOrBeforeMatcher,
});
});
|
5,639 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-date.ts | import { isDate } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an instance of `Date`.
* @example
* expect({ child: { grandchild: new Date('2019-12-31') } }).toHaveDate('child.grandchild');
*/
toHaveDate(propPath: string): boolean;
}
}
}
export const toHaveDateMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isDate(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be an instance of Date`
: `expected value at '${printExpected(propPath)}' to be an instance of Date`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveDate: toHaveDateMatcher,
});
});
|
5,640 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-decimal-number.ts | import { isDecimalNumber } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `Number` with positive decimal places.
* @example
* expect({ child: { grandchild: 12.55 } }).toHaveDecimalNumber('child.grandchild');
*/
toHaveDecimalNumber(propPath: string): boolean;
}
}
}
export const toHaveDecimalNumberMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isDecimalNumber(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be a number with positive decimal places`
: `expected value at '${printExpected(
propPath,
)}' to be a number with positive decimal places`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveDecimalNumber: toHaveDecimalNumberMatcher,
});
});
|
5,641 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-divisible-by.ts | import { isDivisibleBy } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `Number` which results in a whole number when divided by another.
* @example
* expect({ child: { grandchild: 12 } }).toHaveDivisibleBy('child.grandchild', 2);
*/
toHaveDivisibleBy(propPath: string, other: number): boolean;
}
}
}
export const toHaveDivisibleByMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, other: number) {
const pass = isDivisibleBy(other, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be divisible by ${printExpected(
other,
)}`
: `expected value at '${printExpected(propPath)}' to be divisible by ${printExpected(
other,
)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveDivisibleBy: toHaveDivisibleByMatcher,
});
});
|
5,642 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-empty-array.ts | import { isEmptyArray } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a valid `Array` containing no items.
* @example
* expect({ child: { grandchild: [] } }).toHaveEmptyArray('child.grandchild');
*/
toHaveEmptyArray(propPath: string): boolean;
}
}
}
export const toHaveEmptyArrayMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isEmptyArray(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be an array containing no items`
: `expected value at '${printExpected(propPath)}' to be an array containing no items`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveEmptyArray: toHaveEmptyArrayMatcher,
});
});
|
5,643 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-empty-object.ts | import { isEmptyObject } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a valid `Object` containing no instance members.
* @example
* expect({ child: { grandchild: {} } }).toHaveEmptyObject('child.grandchild');
*/
toHaveEmptyObject(propPath: string): boolean;
}
}
}
export const toHaveEmptyObjectMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isEmptyObject(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be an empty object`
: `expected value at '${printExpected(propPath)}' to be an empty object`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveEmptyObject: toHaveEmptyObjectMatcher,
});
});
|
5,644 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-empty-string.ts | import { isEmptyString } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a valid `String` containing no characters.
* @example
* expect({ child: { grandchild: '' } }).toHaveEmptyString('child.grandchild');
*/
toHaveEmptyString(propPath: string): boolean;
}
}
}
export const toHaveEmptyStringMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isEmptyString(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be an empty string or empty instance of String`
: `expected value at '${printExpected(
propPath,
)}' to be an empty string or empty instance of String`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveEmptyString: toHaveEmptyStringMatcher,
});
});
|
5,645 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-ending-with.ts | import { endsWith } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that value is a string whose trailing characters are equal to those of the provided string.
* @example
* expect({ child: { grandchild: 'JavaScript' } }).toHaveEndingWith('child.grandchild', 'Script');
*/
toHaveEndingWith(propPath: string, otherString: unknown): boolean;
}
}
}
export const toHaveEndingWithMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, otherString: unknown) {
const pass = endsWith(otherString, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to end with ${printExpected(
otherString,
)}`
: `expected value at '${printExpected(propPath)}' to end with ${printExpected(
otherString,
)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveEndingWith: toHaveEndingWithMatcher,
});
});
|
5,646 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-even-number.ts | import { isEvenNumber } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an even `Number`.
* @example
* expect({ child: { grandchild: 2 } }).toHaveEvenNumber('child.grandchild');
*/
toHaveEvenNumber(propPath: string): boolean;
}
}
}
export const toHaveEvenNumberMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isEvenNumber(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be an even number`
: `expected value at '${printExpected(propPath)}' to be an even number`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveEvenNumber: toHaveEvenNumberMatcher,
});
});
|
5,647 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-false.ts | import { isFalse } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is `false` or `new Boolean(false)`.
* @example
* expect({ child: { grandchild: false } }).toHaveFalse('child.grandchild');
*/
toHaveFalse(propPath: string): boolean;
}
}
}
export const toHaveFalseMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isFalse(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be false or Boolean(false)`
: `expected value at '${printExpected(propPath)}' to be false or Boolean(false)`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveFalse: toHaveFalseMatcher,
});
});
|
5,648 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-generator-function.ts | import { isGeneratorFunction } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `Function` using `yield` syntax.
* @example
* expect({ child: { grandchild: function* gen() { yield 'i am a generator' } } }).toHaveGeneratorFunction('child.grandchild');
*/
toHaveGeneratorFunction(propPath: string): boolean;
}
}
}
export const toHaveGeneratorFunctionMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isGeneratorFunction(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be a function using yield syntax.`
: `expected value at '${printExpected(propPath)}' to be a function using yield syntax.`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveGeneratorFunction: toHaveGeneratorFunctionMatcher,
});
});
|
5,649 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-greater-than-or-equal-to.ts | import { isGreaterThanOrEqualTo } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is greater than or equal to ${other}.
* @example
* expect({ child: { grandchild: 10 } }).toHaveGreaterThanOrEqualTo('child.grandchild', 5);
*/
toHaveGreaterThanOrEqualTo(propPath: string, other: number): boolean;
}
}
}
export const toHaveGreaterThanOrEqualToMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, other: number) {
const pass = isGreaterThanOrEqualTo(other, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be greater than or equal to ${printExpected(other)}`
: `expected value at '${printExpected(
propPath,
)}' to be greater than or equal to ${printExpected(other)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveGreaterThanOrEqualTo: toHaveGreaterThanOrEqualToMatcher,
});
});
|
5,650 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-iso8601.ts | import { isIso8601 } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a String which conforms to common use-cases of the ISO 8601 standard representation of dates and times.
* @example
* expect({ child: { grandchild: '1999-12-31T23:59:59' } }).toHaveIso8601('child.grandchild');
*/
toHaveIso8601(propPath: string): boolean;
}
}
}
export const toHaveIso8601Matcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isIso8601(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be a valid ISO 8601 date string`
: `expected value at '${printExpected(propPath)}' to be a valid ISO 8601 date string`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveIso8601: toHaveIso8601Matcher,
});
});
|
5,651 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-json-string.ts | import { isJsonString } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `String` of valid JSON.
* @example
* expect({ child: { grandchild: '{"i":"am valid JSON"}' } }).toHaveJsonString('child.grandchild');
*/
toHaveJsonString(propPath: string): boolean;
}
}
}
export const toHaveJsonStringMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isJsonString(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be a string of valid JSON`
: `expected value at '${printExpected(propPath)}' to be a string of valid JSON`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveJsonString: toHaveJsonStringMatcher,
});
});
|
5,652 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-less-than-or-equal-to.ts | import { isLessThanOrEqualTo } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is less than or equal to another.
* @example
* expect({ child: { grandchild: 8 } }).toHaveLessThanOrEqualTo('child.grandchild', 12);
*/
toHaveLessThanOrEqualTo(propPath: string, other: number): boolean;
}
}
}
export const toHaveLessThanOrEqualToMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, other: number) {
const pass = isLessThanOrEqualTo(other, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be less than or equal to ${printExpected(other)}`
: `expected value at '${printExpected(
propPath,
)}' to be less than or equal to ${printExpected(other)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveLessThanOrEqualTo: toHaveLessThanOrEqualToMatcher,
});
});
|
5,653 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-longer-than.ts | import { isLongerThan } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `String` or `Array` whose length is greater than that of another.
* @example
* expect({ child: { grandchild: ['i', 'have', 3] } }).toHaveLongerThan('child.grandchild', [2, 'items']);
*/
toHaveLongerThan(propPath: string, other: string | any[]): boolean;
}
}
}
export const toHaveLongerThanMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, other: string | any[]) {
const pass = isLongerThan(other, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be a string or array whose length is greater than that of ${printExpected(
other,
)}`
: `expected value at '${printExpected(
propPath,
)}' to be a string or array whose length is greater than that of ${printExpected(other)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveLongerThan: toHaveLongerThanMatcher,
});
});
|
5,654 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-method.ts | import { isFunction } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `Function`.
* @example
* expect({ child: { grandchild: () => 'i am a function' } }).toHaveMethod('child.grandchild');
*/
toHaveMethod(propPath: string): boolean;
}
}
}
export const toHaveMethodMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isFunction(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be a function or async function`
: `expected value at '${printExpected(propPath)}' to be a function or async function`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveMethod: toHaveMethodMatcher,
});
});
|
5,655 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-negative-number.ts | import { isNegativeNumber } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `Number` less than 0.
* @example
* expect({ child: { grandchild: -18 } }).toHaveNegativeNumber('child.grandchild');
*/
toHaveNegativeNumber(propPath: string): boolean;
}
}
}
export const toHaveNegativeNumberMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isNegativeNumber(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be a negative number`
: `expected value at '${printExpected(propPath)}' to be a negative number`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveNegativeNumber: toHaveNegativeNumberMatcher,
});
});
|
5,656 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-nil.ts | import { isNil } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is `null` or `undefined`
* @example
* expect({ child: { grandchild: undefined } }).toHaveNil('child.grandchild');
*/
toHaveNil(propPath: string): boolean;
}
}
}
export const toHaveNilMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isNil(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be null or undefined`
: `expected value at '${printExpected(propPath)}' to be null or undefined`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveNil: toHaveNilMatcher,
});
});
|
5,657 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-non-empty-array.ts | import { isNonEmptyArray } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an `Array` containing at least one value.
* @example
* expect({ child: { grandchild: ['i', 'am not empty'] } }).toHaveNonEmptyArray('child.grandchild');
*/
toHaveNonEmptyArray(propPath: string): boolean;
}
}
}
export const toHaveNonEmptyArrayMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isNonEmptyArray(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be an array with at least one item`
: `expected value at '${printExpected(propPath)}' to be an array with at least one item`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveNonEmptyArray: toHaveNonEmptyArrayMatcher,
});
});
|
5,658 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-non-empty-object.ts | import { isNonEmptyObject } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an `Object` containing at least one own member.
* @example
* expect({ child: { grandchild: { i: 'am not empty' } } }).toHaveNonEmptyObject('child.grandchild');
*/
toHaveNonEmptyObject(propPath: string): boolean;
}
}
}
export const toHaveNonEmptyObjectMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isNonEmptyObject(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be an object with at least one own member`
: `expected value at '${printExpected(
propPath,
)}' to be an object with at least one own member`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveNonEmptyObject: toHaveNonEmptyObjectMatcher,
});
});
|
5,659 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-non-empty-string.ts | import { isNonEmptyString } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a valid `String` containing at least one character.
* @example
* expect({ child: { grandchild: 'i am not empty' } }).toHaveNonEmptyString('child.grandchild');
*/
toHaveNonEmptyString(propPath: string): boolean;
}
}
}
export const toHaveNonEmptyStringMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isNonEmptyString(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be a string with at least one character`
: `expected value at '${printExpected(
propPath,
)}' to be a string with at least one character`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveNonEmptyString: toHaveNonEmptyStringMatcher,
});
});
|
5,660 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-null.ts | import { isNull } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is `null`.
* @example
* expect({ child: { grandchild: null } }).toHaveNull('child.grandchild');
*/
toHaveNull(propPath: string): boolean;
}
}
}
export const toHaveNullMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isNull(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be null`
: `expected value at '${printExpected(propPath)}' to be null`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveNull: toHaveNullMatcher,
});
});
|
5,661 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-number-near.ts | import { isNear } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a number within the given acceptable distance from another.
* @example
* expect({ child: { grandchild: 4.8 } }).toHaveNumberNear('child.grandchild', 5, 0.5);
*/
toHaveNumberNear(propPath: string, otherNumber: number, epsilon: number): boolean;
}
}
}
export const toHaveNumberNearMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, otherNumber: number, epsilon: number) {
const pass = isNear(otherNumber, epsilon, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be within ${printExpected(
epsilon,
)} greater or less than ${printExpected(otherNumber)}`
: `expected value at '${printExpected(propPath)}' to be within ${printExpected(
epsilon,
)} greater or less than ${printExpected(otherNumber)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveNumberNear: toHaveNumberNearMatcher,
});
});
|
5,662 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-number-within-range.ts | import { isWithinRange } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `Number` which is both greater than or equal to `floor` and less than or equal to `ceiling`.
* @example
* expect({ child: { grandchild: 7 } }).toHaveNumberWithinRange('child.grandchild', 0, 10);
*/
toHaveNumberWithinRange(propPath: string, floor: number, ceiling: number): boolean;
}
}
}
export const toHaveNumberWithinRangeMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, floor: number, ceiling: number) {
const pass = isWithinRange(floor, ceiling, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be greater than or equal to ${printExpected(
floor,
)} and less than or equal to ${printExpected(ceiling)}`
: `expected value at '${printExpected(
propPath,
)}' to be greater than or equal to ${printExpected(
floor,
)} and less than or equal to ${printExpected(ceiling)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveNumberWithinRange: toHaveNumberWithinRangeMatcher,
});
});
|
5,663 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-number.ts | import { isNumber } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a valid `Number` or `new Number()` and not `NaN`.
* @example
* expect({ child: { grandchild: 8 } }).toHaveNumber('child.grandchild');
*/
toHaveNumber(propPath: string): boolean;
}
}
}
export const toHaveNumberMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isNumber(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be a valid number`
: `expected value at '${printExpected(propPath)}' to be a valid number`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveNumber: toHaveNumberMatcher,
});
});
|
5,664 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-object.ts | import { isObject } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an `Object`.
* @example
* expect({ child: { grandchild: {} } }).toHaveObject('child.grandchild');
*/
toHaveObject(propPath: string): boolean;
}
}
}
export const toHaveObjectMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isObject(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be an object`
: `expected value at '${printExpected(propPath)}' to be an object`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveObject: toHaveObjectMatcher,
});
});
|
5,665 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-odd-number.ts | import { isOddNumber } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an odd `Number`.
* @example
* expect({ child: { grandchild: 5 } }).toHaveOddNumber('child.grandchild');
*/
toHaveOddNumber(propPath: string): boolean;
}
}
}
export const toHaveOddNumberMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isOddNumber(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be an odd number`
: `expected value at '${printExpected(propPath)}' to be an odd number`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveOddNumber: toHaveOddNumberMatcher,
});
});
|
5,666 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-positive-number.ts | import { isPositiveNumber } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `Number` greater than 0.
* @example
* expect({ child: { grandchild: 5 } }).toHavePositiveNumber('child.grandchild');
*/
toHavePositiveNumber(propPath: string): boolean;
}
}
}
export const toHavePositiveNumberMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isPositiveNumber(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be a positive number`
: `expected value at '${printExpected(propPath)}' to be a positive number`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHavePositiveNumber: toHavePositiveNumberMatcher,
});
});
|
5,667 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-reg-exp.ts | import { isRegExp } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `RegExp`.
* @example
* expect({ child: { grandchild: new RegExp('i am a regular expression') } }).toHaveRegExp('child.grandchild');
*/
toHaveRegExp(propPath: string): boolean;
}
}
}
export const toHaveRegExpMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isRegExp(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be a regular expression`
: `expected value at '${printExpected(propPath)}' to be a regular expression`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveRegExp: toHaveRegExpMatcher,
});
});
|
5,668 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-same-length-as.ts | import { isSameLengthAs } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `String` or `Array` whose length is the same as that of the other provided.
* @example
* expect({ child: { grandchild: ['i also have', '2 items'] } }).toHaveSameLengthAs('child.grandchild', ['i have', '2 items']);
*/
toHaveSameLengthAs(propPath: string, other: string | any[]): boolean;
}
}
}
export const toHaveSameLengthAsMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, other: string | any[]) {
const pass = isSameLengthAs(other, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be a string or array whose length is the same as that of ${printExpected(
other,
)}`
: `expected value at '${printExpected(
propPath,
)}' to be a string or array whose length is the same as that of ${printExpected(other)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveSameLengthAs: toHaveSameLengthAsMatcher,
});
});
|
5,669 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-shorter-than.ts | import { isShorterThan } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `String` or `Array` whose length is less than that of the other provided.
* @example
* expect({ child: { grandchild: ['i have one item'] } }).toHaveShorterThan('child.grandchild', ['i', 'have', 4, 'items']);
*/
toHaveShorterThan(propPath: string, other: string | any[]): boolean;
}
}
}
export const toHaveShorterThanMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, other: string | any[]) {
const pass = isShorterThan(other, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be a string or array whose length is less than that of ${printExpected(other)}`
: `expected value at '${printExpected(
propPath,
)}' to be a string or array whose length is less than that of ${printExpected(other)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveShorterThan: toHaveShorterThanMatcher,
});
});
|
5,670 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-starting-with.ts | import { startsWith } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that value is a string whose trailing characters are equal to those of the provided string.
* @example
* expect({ child: { grandchild: 'JavaScript' } }).toHaveStartingWith('child.grandchild', 'Java');
*/
toHaveStartingWith(propPath: string, otherString: string): boolean;
}
}
}
export const toHaveStartingWithMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string, otherString: string) {
const pass = startsWith(otherString, getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to start with ${printExpected(
otherString,
)}`
: `expected value at '${printExpected(propPath)}' to start with ${printExpected(
otherString,
)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveStartingWith: toHaveStartingWithMatcher,
});
});
|
5,671 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-string.ts | import { isString } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `String` or `new String()`.
* @example
* expect({ child: { grandchild: 'i am a string' } }).toHaveString('child.grandchild');
*/
toHaveString(propPath: string): boolean;
}
}
}
export const toHaveStringMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isString(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be a string`
: `expected value at '${printExpected(propPath)}' to be a string`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveString: toHaveStringMatcher,
});
});
|
5,672 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-true.ts | import { isTrue } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is `true` or `new Boolean(true)`.
* @example
* expect({ child: { grandchild: true } }).toHaveTrue('child.grandchild');
*/
toHaveTrue(propPath: string): boolean;
}
}
}
export const toHaveTrueMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isTrue(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be true or Boolean(true)`
: `expected value at '${printExpected(propPath)}' to be true or Boolean(true)`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveTrue: toHaveTrueMatcher,
});
});
|
5,673 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-undefined.ts | import { isUndefined } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is `undefined`
* @example
* expect({ child: { grandchild: undefined } }).toHaveUndefined('child.grandchild');
*/
toHaveUndefined(propPath: string): boolean;
}
}
}
export const toHaveUndefinedMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isUndefined(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be undefined`
: `expected value at '${printExpected(propPath)}' to be undefined`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveUndefined: toHaveUndefinedMatcher,
});
});
|
5,674 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-valid-date.ts | import { isValidDate } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is an instance of `Date` whose internal value is valid. `Date` is little like `Promise` in that it is a container for a value. For example, `new Date('wut?')` is a valid `Date` which wraps a value that is not valid.
* @example
* expect({ child: { grandchild: new Date('2020-01-01') } }).toHaveValidDate('child.grandchild');
*/
toHaveValidDate(propPath: string): boolean;
}
}
}
export const toHaveValidDateMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isValidDate(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be an instance of Date with a valid value`
: `expected value at '${printExpected(
propPath,
)}' to be an instance of Date with a valid value`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveValidDate: toHaveValidDateMatcher,
});
});
|
5,675 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-visible-string.ts | import { isVisibleString } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a valid `String` containing at least one character which is not whitespace.
* @example
* expect({ child: { grandchild: 'i am visible' } }).toHaveVisibleString('child.grandchild');
*/
toHaveVisibleString(propPath: string): boolean;
}
}
}
export const toHaveVisibleStringMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isVisibleString(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be a string with at least one non-whitespace character`
: `expected value at '${printExpected(
propPath,
)}' to be a string with at least one non-whitespace character`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveVisibleString: toHaveVisibleStringMatcher,
});
});
|
5,676 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-walkable.ts | import { isWalkable } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is safe to attempt to read property values from.
* @example
* expect({ child: { grandchild: {} } }).toHaveWalkable('child.grandchild');
*/
toHaveWalkable(propPath: string): boolean;
}
}
}
export const toHaveWalkableMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isWalkable(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be walkable`
: `expected value at '${printExpected(propPath)}' to be walkable`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveWalkable: toHaveWalkableMatcher,
});
});
|
5,677 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-whitespace.ts | import { isWhitespace } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `String` containing only whitespace characters.
* @example
* expect({ child: { grandchild: ' ' } }).toHaveWhitespace('child.grandchild');
*/
toHaveWhitespace(propPath: string): boolean;
}
}
}
export const toHaveWhitespaceMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isWhitespace(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(
propPath,
)}' not to be a string containing only whitespace characters`
: `expected value at '${printExpected(
propPath,
)}' to be a string containing only whitespace characters`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveWhitespace: toHaveWhitespaceMatcher,
});
});
|
5,678 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-have-whole-number.ts | import { isWholeNumber } from 'expect-more';
import { printExpected } from 'jest-matcher-utils';
import { getIn } from './lib/get-in';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that a value is a `Number` with no positive decimal places.
* @example
* expect({ child: { grandchild: 8 } }).toHaveWholeNumber('child.grandchild');
*/
toHaveWholeNumber(propPath: string): boolean;
}
}
}
export const toHaveWholeNumberMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, propPath: string) {
const pass = isWholeNumber(getIn(propPath.split('.'), value));
const message = pass
? `expected value at '${printExpected(propPath)}' not to be a whole number`
: `expected value at '${printExpected(propPath)}' to be a whole number`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toHaveWholeNumber: toHaveWholeNumberMatcher,
});
});
|
5,679 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine | petrpan-code/JamieMason/expect-more/packages/expect-more-jasmine/src/to-start-with.ts | /// <reference types="jasmine" />
import { startsWith } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
declare global {
namespace jasmine {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers<T> {
/**
* Asserts that value is a string whose trailing characters are equal to those of the provided string.
* @example
* expect('JavaScript').toStartWith('Java');
*/
toStartWith(otherString: string): boolean;
}
}
}
export const toStartWithMatcher: jasmine.CustomMatcherFactory = () => {
return {
compare(value: unknown, otherString: string) {
const pass = startsWith(otherString, value);
const message = pass
? `expected ${printReceived(value)} not to start with ${printExpected(otherString)}`
: `expected ${printReceived(value)} to start with ${printExpected(otherString)}`;
return { message, pass };
},
};
};
beforeAll(() => {
jasmine.addMatchers({
toStartWith: toStartWithMatcher,
});
});
|
5,798 | 0 | petrpan-code/JamieMason/expect-more/packages | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/package.json | {
"name": "expect-more-jest",
"description": "Write Beautiful Specs with Custom Matchers for Jest",
"version": "5.5.0",
"author": "Jamie Mason <jamie@foldleft.io> (https://github.com/JamieMason)",
"bugs": "https://github.com/JamieMason/expect-more/issues",
"contributors": [
"Haroen Viaene (https://github.com/Haroenv)"
],
"dependencies": {
"@jest/expect-utils": "29.4.1",
"expect-more": "1.3.0",
"jest-matcher-utils": "29.4.1"
},
"files": [
"dist"
],
"homepage": "https://github.com/JamieMason/expect-more/tree/master/packages/expect-more-jest/#readme",
"keywords": [
"assertions",
"ava",
"bdd",
"expect",
"jasmine",
"jest",
"matchers",
"mocha",
"mock",
"spy",
"tdd",
"test",
"test-matchers",
"testing",
"unit"
],
"license": "MIT",
"main": "dist/index.js",
"repository": "JamieMason/expect-more",
"scripts": {
"prepublish": "cd ../../ && npm run build:expect-more-jest"
},
"typings": "./dist/index.d.ts"
}
|
5,801 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-after.ts | /// <reference types="jest" />
import { isAfter } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is a valid instance of `Date` whose value occurs after that of another.
* @example
* expect(new Date('2020-01-01')).toBeAfter(new Date('2019-12-31'));
*/
toBeAfter(otherDate: Date): R;
}
interface Expect {
/**
* Asserts that a value is a valid instance of `Date` whose value occurs after that of another.
* @example
* expect(new Date('2020-01-01')).toEqual(
* expect.toBeAfter(new Date('2019-12-31'))
* );
*/
toBeAfter<T>(otherDate: Date): JestMatchers<T>;
}
}
}
export const toBeAfterMatcher = (value: unknown, otherDate: Date): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(value)} to be an instance of Date, occurring after ${printExpected(
otherDate,
)}`,
notMessage: () =>
`expected ${printReceived(
value,
)} not to be an instance of Date, occurring after ${printExpected(otherDate)}`,
pass: isAfter(otherDate, value),
});
expect.extend({ toBeAfter: toBeAfterMatcher });
|
5,802 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-array-including-all-of.ts | /// <reference types="jest" />
import { isArrayIncludingAllOf } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that `value` is an `Array` including all of the values provided in `requiredValues`. It could also include additional values or be in a different order, but if every value in `requiredValues` features in `value` then this will return `true`.
* @example
* expect([12, 0, 14, 'Ivo']).toBeArrayIncludingAllOf(['Ivo', 14]);
*/
toBeArrayIncludingAllOf(requiredValues: unknown[]): R;
}
interface Expect {
/**
* Asserts that `value` is an `Array` including all of the values provided in `requiredValues`. It could also include additional values or be in a different order, but if every value in `requiredValues` features in `value` then this will return `true`.
* @example
* expect([12, 0, 14, 'Ivo']).toEqual(
* expect.toBeArrayIncludingAllOf(['Ivo', 14])
* );
*/
toBeArrayIncludingAllOf<T>(requiredValues: unknown[]): JestMatchers<T>;
}
}
}
export const toBeArrayIncludingAllOfMatcher = (
value: unknown,
requiredValues: unknown[],
): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(value)} to include every value provided in ${printExpected(
requiredValues,
)}`,
notMessage: () =>
`expected ${printReceived(value)} not to include every value provided in ${printExpected(
requiredValues,
)}`,
pass: isArrayIncludingAllOf(requiredValues, value),
});
expect.extend({ toBeArrayIncludingAllOf: toBeArrayIncludingAllOfMatcher });
|
5,803 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-array-including-any-of.ts | /// <reference types="jest" />
import { isArrayIncludingAnyOf } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that `value` is an `Array` including at least one of the members of `allowedValues`.
* @example
* expect([12, 0, 14, 'Ginola']).toBeArrayIncludingAnyOf(['Ginola', 3]);
*/
toBeArrayIncludingAnyOf(allowedValues: unknown[]): R;
}
interface Expect {
/**
* Asserts that `value` is an `Array` including at least one of the members of `allowedValues`.
* @example
* expect([12, 0, 14, 'Ginola']).toEqual(
* expect.toBeArrayIncludingAnyOf(['Ginola', 3])
* );
*/
toBeArrayIncludingAnyOf<T>(allowedValues: unknown[]): JestMatchers<T>;
}
}
}
export const toBeArrayIncludingAnyOfMatcher = (
value: unknown,
allowedValues: unknown[],
): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(value)} to include at least one of the values in ${printExpected(
allowedValues,
)}`,
notMessage: () =>
`expected ${printReceived(
value,
)} not to include at least one of the values in ${printExpected(allowedValues)}`,
pass: isArrayIncludingAnyOf(allowedValues, value),
});
expect.extend({ toBeArrayIncludingAnyOf: toBeArrayIncludingAnyOfMatcher });
|
5,804 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-array-including-only.ts | /// <reference types="jest" />
import { isArrayIncludingOnly } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an `Array` including only the values provided in the given `allowedValues` array and no others. The order and number of times each value appears in either array does not matter. Returns true unless `value` contains a value which does not feature in `allowedValues`.
* @example
* expect([5, 10, 1]).toBeArrayIncludingOnly([1, 5, 10]);
*/
toBeArrayIncludingOnly(allowedValues: unknown[]): R;
}
interface Expect {
/**
* Asserts that a value is an `Array` including only the values provided in the given `allowedValues` array and no others. The order and number of times each value appears in either array does not matter. Returns true unless `value` contains a value which does not feature in `allowedValues`.
* @example
* expect([5, 10, 1]).toEqual(
* expect.toBeArrayIncludingOnly([1, 5, 10])
* );
*/
toBeArrayIncludingOnly<T>(allowedValues: unknown[]): JestMatchers<T>;
}
}
}
export const toBeArrayIncludingOnlyMatcher = (
value: unknown,
allowedValues: unknown[],
): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(value)} to only include values featured in ${printExpected(
allowedValues,
)} and no others`,
notMessage: () =>
`expected ${printReceived(value)} not to only include values featured in ${printExpected(
allowedValues,
)} and no others`,
pass: isArrayIncludingOnly(allowedValues, value),
});
expect.extend({ toBeArrayIncludingOnly: toBeArrayIncludingOnlyMatcher });
|
5,805 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-array-of-booleans.ts | /// <reference types="jest" />
import { isArrayOfBooleans } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an `Array` containing only `Boolean` values.
* @example
* expect([true, false, new Boolean(true)]).toBeArrayOfBooleans();
*/
toBeArrayOfBooleans(): R;
}
interface Expect {
/**
* Asserts that a value is an `Array` containing only `Boolean` values.
* @example
* expect([true, false, new Boolean(true)]).toEqual(
* expect.toBeArrayOfBooleans()
* );
*/
toBeArrayOfBooleans<T>(): JestMatchers<T>;
}
}
}
export const toBeArrayOfBooleansMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(value)} to be a non-empty array, containing only boolean values`,
notMessage: () =>
`expected ${printReceived(
value,
)} not to be a non-empty array, containing only boolean values`,
pass: isArrayOfBooleans(value),
});
expect.extend({ toBeArrayOfBooleans: toBeArrayOfBooleansMatcher });
|
5,806 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-array-of-numbers.ts | /// <reference types="jest" />
import { isArrayOfNumbers } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an `Array` containing only `Number` values.
* @example
* expect([12, 0, 14]).toBeArrayOfNumbers();
*/
toBeArrayOfNumbers(): R;
}
interface Expect {
/**
* Asserts that a value is an `Array` containing only `Number` values.
* @example
* expect([12, 0, 14]).toEqual(
* expect.toBeArrayOfNumbers()
* );
*/
toBeArrayOfNumbers<T>(): JestMatchers<T>;
}
}
}
export const toBeArrayOfNumbersMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(value)} to be a non-empty array, containing only numbers`,
notMessage: () =>
`expected ${printReceived(value)} not to be a non-empty array, containing only numbers`,
pass: isArrayOfNumbers(value),
});
expect.extend({ toBeArrayOfNumbers: toBeArrayOfNumbersMatcher });
|
5,807 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-array-of-objects.ts | /// <reference types="jest" />
import { isArrayOfObjects } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an `Array` containing only `Object` values.
* @example
* expect([{}, new Object()]).toBeArrayOfObjects();
*/
toBeArrayOfObjects(): R;
}
interface Expect {
/**
* Asserts that a value is an `Array` containing only `Object` values.
* @example
* expect([{}, new Object()]).toEqual(
* expect.toBeArrayOfObjects()
* );
*/
toBeArrayOfObjects<T>(): JestMatchers<T>;
}
}
}
export const toBeArrayOfObjectsMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(value)} to be a non-empty array, containing only objects`,
notMessage: () =>
`expected ${printReceived(value)} not to be a non-empty array, containing only objects`,
pass: isArrayOfObjects(value),
});
expect.extend({ toBeArrayOfObjects: toBeArrayOfObjectsMatcher });
|
5,808 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-array-of-size.ts | /// <reference types="jest" />
import { isArrayOfSize } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an `Array` containing a specific number of values.
* @example
* expect(['i', 'contain', 4, 'items']).toBeArrayOfSize(4);
*/
toBeArrayOfSize(size: number): R;
}
interface Expect {
/**
* Asserts that a value is an `Array` containing a specific number of values.
* @example
* expect(['i', 'contain', 4, 'items']).toEqual(
* expect.toBeArrayOfSize(4)
* );
*/
toBeArrayOfSize<T>(size: number): JestMatchers<T>;
}
}
}
export const toBeArrayOfSizeMatcher = (value: unknown, size: number): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(value)} to be an array containing exactly ${printExpected(
size,
)} items`,
notMessage: () =>
`expected ${printReceived(value)} not to be an array containing exactly ${printExpected(
size,
)} items`,
pass: isArrayOfSize(size, value),
});
expect.extend({ toBeArrayOfSize: toBeArrayOfSizeMatcher });
|
5,809 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-array-of-strings.ts | /// <reference types="jest" />
import { isArrayOfStrings } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an `Array` containing only `String` values.
* @example
* expect(['we', 'are', 'all', 'strings']).toBeArrayOfStrings();
*/
toBeArrayOfStrings(): R;
}
interface Expect {
/**
* Asserts that a value is an `Array` containing only `String` values.
* @example
* expect(['we', 'are', 'all', 'strings']).toEqual(
* expect.toBeArrayOfStrings()
* );
*/
toBeArrayOfStrings<T>(): JestMatchers<T>;
}
}
}
export const toBeArrayOfStringsMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(value)} to be a non-empty array, containing only strings`,
notMessage: () =>
`expected ${printReceived(value)} not to be a non-empty array, containing only strings`,
pass: isArrayOfStrings(value),
});
expect.extend({ toBeArrayOfStrings: toBeArrayOfStringsMatcher });
|
5,810 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-array-of.ts | import { equals } from '@jest/expect-utils';
import { isArray } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an `Array` where every member is equal to ${other}.
* @example
* expect([{ name: 'Guybrush' }, { name: 'Elaine' }]).toBeArrayOf({
* name: expect.toBeNonEmptyString()
* });
*/
toBeArrayOf(other: unknown): R;
}
interface Expect {
/**
* Asserts that a value is an `Array` containing only `Boolean` values.
* @example
* expect([{ name: 'Guybrush' }, { name: 'Elaine' }]).toEqual(
* expect.toBeArrayOf({ name: expect.toBeNonEmptyString() })
* );
*/
toBeArrayOf<T>(other: unknown): JestMatchers<T>;
}
}
}
export const toBeArrayOfMatcher = (value: unknown, other: unknown): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(
value,
)} to be an array, containing only values equal to ${printExpected(other)}`,
notMessage: () =>
`expected ${printReceived(
value,
)} not to be a non-empty array, containing only values equal to ${printExpected(other)}`,
pass: isArray(value) && value.every((member) => equals(member, other)),
});
expect.extend({ toBeArrayOf: toBeArrayOfMatcher });
|
5,811 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-array.ts | /// <reference types="jest" />
import { isArray } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is a valid `Array` containing none or any number of items of any type.
* @example
* expect([2, true, 'string']).toBeArray();
*/
toBeArray(): R;
}
interface Expect {
/**
* Asserts that a value is a valid `Array` containing none or any number of items of any type.
* @example
* expect([2, true, 'string']).toEqual(
* expect.toBeArray()
* );
*/
toBeArray<T>(): JestMatchers<T>;
}
}
}
export const toBeArrayMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () => `expected ${printReceived(value)} to be an array`,
notMessage: () => `expected ${printReceived(value)} not to be an array`,
pass: isArray(value),
});
expect.extend({ toBeArray: toBeArrayMatcher });
|
5,812 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-async-function.ts | /// <reference types="jest" />
import { isAsyncFunction } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is a function using `async` and `await` syntax.
* @example
* expect(async () => { await fetch('...') }).toBeAsyncFunction();
*/
toBeAsyncFunction(): R;
}
interface Expect {
/**
* Asserts that a value is a function using `async` and `await` syntax.
* @example
* expect(async () => { await fetch('...') }).toEqual(
* expect.toBeAsyncFunction()
* );
*/
toBeAsyncFunction<T>(): JestMatchers<T>;
}
}
}
export const toBeAsyncFunctionMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () => `expected ${printReceived(value)} to be a \`Function\` using async/await syntax`,
notMessage: () =>
`expected ${printReceived(value)} not to be a function using async/await syntax`,
pass: isAsyncFunction(value),
});
expect.extend({ toBeAsyncFunction: toBeAsyncFunctionMatcher });
|
5,813 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-before.ts | /// <reference types="jest" />
import { isBefore } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is a valid instance of `Date` whose value occurs before that of another.
* @example
* expect(new Date('2019-12-31')).toBeBefore(new Date('2020-01-01'));
*/
toBeBefore(other: Date): R;
}
interface Expect {
/**
* Asserts that a value is a valid instance of `Date` whose value occurs before that of another.
* @example
* expect(new Date('2019-12-31')).toEqual(
* expect.toBeBefore(new Date('2020-01-01'))
* );
*/
toBeBefore<T>(other: Date): JestMatchers<T>;
}
}
}
export const toBeBeforeMatcher = (value: unknown, other: Date): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(value)} to be an instance of Date, occurring before ${printExpected(
other,
)}`,
notMessage: () =>
`expected ${printReceived(
value,
)} not to be an instance of Date, occurring before ${printExpected(other)}`,
pass: isBefore(other, value),
});
expect.extend({ toBeBefore: toBeBeforeMatcher });
|
5,814 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-boolean.ts | /// <reference types="jest" />
import { isBoolean } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is `true`, `false`, `new Boolean(true)`, or `new Boolean(false)`.
* @example
* expect(false).toBeBoolean();
*/
toBeBoolean(): R;
}
interface Expect {
/**
* Asserts that a value is `true`, `false`, `new Boolean(true)`, or `new Boolean(false)`.
* @example
* expect(false).toEqual(
* expect.toBeBoolean()
* );
*/
toBeBoolean<T>(): JestMatchers<T>;
}
}
}
export const toBeBooleanMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () => `expected ${printReceived(value)} to be true, false, or an instance of Boolean`,
notMessage: () =>
`expected ${printReceived(value)} not to be true, false, or an instance of Boolean`,
pass: isBoolean(value),
});
expect.extend({ toBeBoolean: toBeBooleanMatcher });
|
5,815 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-calculable.ts | /// <reference types="jest" />
import { isCalculable } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Assert value can be used in Mathemetic calculations despite not being a `Number`, for example `'1' * '2' === 2` whereas `'wut?' * 2 === NaN`.
* @example
* expect('100').toBeCalculable();
*/
toBeCalculable(): R;
}
interface Expect {
/**
* Assert value can be used in Mathemetic calculations despite not being a `Number`, for example `'1' * '2' === 2` whereas `'wut?' * 2 === NaN`.
* @example
* expect('100').toEqual(
* expect.toBeCalculable()
* );
*/
toBeCalculable<T>(): JestMatchers<T>;
}
}
}
export const toBeCalculableMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(value)} to be coercible for use in mathemetical operations`,
notMessage: () =>
`expected ${printReceived(value)} not to be coercible for use in mathemetical operations`,
pass: isCalculable(value),
});
expect.extend({ toBeCalculable: toBeCalculableMatcher });
|
5,816 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-date-between.ts | /// <reference types="jest" />
import { isDateBetween } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an instance of `Date` occurring on or after `floor` and on or before `ceiling`.
* @example
* expect(new Date('2019-12-11')).toBeDateBetween(new Date('2019-12-10'), new Date('2019-12-12'));
*/
toBeDateBetween(floor: unknown, ceiling: unknown): R;
}
interface Expect {
/**
* Asserts that a value is an instance of `Date` occurring on or after `floor` and on or before `ceiling`.
* @example
* expect(new Date('2019-12-11')).toEqual(
* expect.toBeDateBetween(new Date('2019-12-10'), new Date('2019-12-12'))
* );
*/
toBeDateBetween<T>(floor: unknown, ceiling: unknown): JestMatchers<T>;
}
}
}
export const toBeDateBetweenMatcher = (
value: unknown,
floor: unknown,
ceiling: unknown,
): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(
value,
)} to be an instance of Date occurring on or after ${printExpected(
floor,
)} and on or before ${printExpected(ceiling)}`,
notMessage: () =>
`expected ${printReceived(
value,
)} not to be an instance of Date occurring on or after ${printExpected(
floor,
)} and on or before ${printExpected(ceiling)}`,
pass: isDateBetween(floor, ceiling, value),
});
expect.extend({ toBeDateBetween: toBeDateBetweenMatcher });
|
5,817 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-date-in-month.ts | /// <reference types="jest" />
import { isDateInMonth } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an instance of `Date` occurring on the given month of the year, where January is `0` and December is `11`.
* @example
* expect(new Date('2021-08-29')).toBeDateInMonth(7);
*/
toBeDateInMonth(index: number): R;
}
interface Expect {
/**
* Asserts that a value is an instance of `Date` occurring on the given month of the year, where January is `0` and December is `11`.
* @example
* expect(new Date('2021-08-29')).toEqual(
* expect.toBeDateInMonth(7)
* );
*/
toBeDateInMonth<T>(index: number): JestMatchers<T>;
}
}
}
export const toBeDateInMonthMatcher = (value: unknown, index: number): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(
value,
)} to be an instance of Date occurring on the month of the year with index ${printExpected(
index,
)}`,
notMessage: () =>
`expected ${printReceived(
value,
)} not to be an instance of Date occurring on the month of the year with index ${printExpected(
index,
)}`,
pass: isDateInMonth(index, value),
});
expect.extend({ toBeDateInMonth: toBeDateInMonthMatcher });
|
5,818 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-date-in-year.ts | /// <reference types="jest" />
import { isDateInYear } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an instance of `Date` occurring in the given year.
* @example
* expect(new Date('2021-08-29')).toBeDateInYear(2021);
*/
toBeDateInYear(year: number): R;
}
interface Expect {
/**
* Asserts that a value is an instance of `Date` occurring in the given year.
* @example
* expect(new Date('2021-08-29')).toEqual(
* expect.toBeDateInYear(2021)
* );
*/
toBeDateInYear<T>(year: number): JestMatchers<T>;
}
}
}
export const toBeDateInYearMatcher = (value: unknown, year: number): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(
value,
)} to be an instance of Date occurring in the year ${printExpected(year)}`,
notMessage: () =>
`expected ${printReceived(
value,
)} not to be an instance of Date occurring in the year ${printExpected(year)}`,
pass: isDateInYear(year, value),
});
expect.extend({ toBeDateInYear: toBeDateInYearMatcher });
|
5,819 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-date-on-day-of-month.ts | /// <reference types="jest" />
import { isDateOnDayOfMonth } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an instance of `Date` occurring on the given day of the month, where the first day of the month is `1` and last is `31`.
* @example
* expect(new Date('2021-08-29')).toBeDateOnDayOfMonth(29);
*/
toBeDateOnDayOfMonth(dayOfMonth: number): R;
}
interface Expect {
/**
* Asserts that a value is an instance of `Date` occurring on the given day of the month, where the first day of the month is `1` and last is `31`.
* @example
* expect(new Date('2021-08-29')).toEqual(
* expect.toBeDateOnDayOfMonth(29)
* );
*/
toBeDateOnDayOfMonth<T>(dayOfMonth: number): JestMatchers<T>;
}
}
}
export const toBeDateOnDayOfMonthMatcher = (
value: unknown,
dayOfMonth: number,
): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(value)} to be an instance of Date occurring on the ${printExpected(
dayOfMonth,
)} day of the month`,
notMessage: () =>
`expected ${printReceived(
value,
)} not to be an instance of Date occurring on the ${printExpected(
dayOfMonth,
)} day of the month`,
pass: isDateOnDayOfMonth(dayOfMonth, value),
});
expect.extend({ toBeDateOnDayOfMonth: toBeDateOnDayOfMonthMatcher });
|
5,820 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-date-on-day-of-week.ts | /// <reference types="jest" />
import { isDateOnDayOfWeek } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an instance of `Date` occurring on the day of the week with the given index, where Sunday is `0` and Saturday is `6`.
* @example
* expect(new Date('2021-08-29')).toBeDateOnDayOfWeek(0);
*/
toBeDateOnDayOfWeek(index: number): R;
}
interface Expect {
/**
* Asserts that a value is an instance of `Date` occurring on the day of the week with the given index, where Sunday is `0` and Saturday is `6`.
* @example
* expect(new Date('2021-08-29')).toEqual(
* expect.toBeDateOnDayOfWeek(0)
* );
*/
toBeDateOnDayOfWeek<T>(index: number): JestMatchers<T>;
}
}
}
export const toBeDateOnDayOfWeekMatcher = (
value: unknown,
index: number,
): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(
value,
)} to be an instance of Date occurring on the day of the week with index ${printExpected(
index,
)}`,
notMessage: () =>
`expected ${printReceived(
value,
)} not to be an instance of Date occurring on the day of the week with index ${printExpected(
index,
)}`,
pass: isDateOnDayOfWeek(index, value),
});
expect.extend({ toBeDateOnDayOfWeek: toBeDateOnDayOfWeekMatcher });
|
5,821 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-date-on-or-after.ts | /// <reference types="jest" />
import { isDateOnOrAfter } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an instance of `Date` occurring on or after the exact date and time of another.
* @example
* expect(new Date('2019-12-31')).toBeDateOnOrAfter(new Date('2019-12-15'));
*/
toBeDateOnOrAfter(other: unknown): R;
}
interface Expect {
/**
* Asserts that a value is an instance of `Date` occurring on or after the exact date and time of another.
* @example
* expect(new Date('2019-12-31')).toEqual(
* expect.toBeDateOnOrAfter(new Date('2019-12-15'))
* );
*/
toBeDateOnOrAfter<T>(other: unknown): JestMatchers<T>;
}
}
}
export const toBeDateOnOrAfterMatcher = (
value: unknown,
other: unknown,
): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(
value,
)} to be an instance of Date occurring on or after ${printExpected(other)}`,
notMessage: () =>
`expected ${printReceived(
value,
)} not to be an instance of Date occurring on or after ${printExpected(other)}`,
pass: isDateOnOrAfter(other, value),
});
expect.extend({ toBeDateOnOrAfter: toBeDateOnOrAfterMatcher });
|
5,822 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-date-on-or-before.ts | /// <reference types="jest" />
import { isDateOnOrBefore } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an instance of `Date` occurring on or before the exact date and time of another.
* @example
* expect(new Date('2019-12-15')).toBeDateOnOrBefore(new Date('2019-12-31'));
*/
toBeDateOnOrBefore(other: unknown): R;
}
interface Expect {
/**
* Asserts that a value is an instance of `Date` occurring on or before the exact date and time of another.
* @example
* expect(new Date('2019-12-15')).toEqual(
* expect.toBeDateOnOrBefore(new Date('2019-12-31'))
* );
*/
toBeDateOnOrBefore<T>(other: unknown): JestMatchers<T>;
}
}
}
export const toBeDateOnOrBeforeMatcher = (
value: unknown,
other: unknown,
): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(
value,
)} to be an instance of Date occurring on or before ${printExpected(other)}`,
notMessage: () =>
`expected ${printReceived(
value,
)} not to be an instance of Date occurring on or before ${printExpected(other)}`,
pass: isDateOnOrBefore(other, value),
});
expect.extend({ toBeDateOnOrBefore: toBeDateOnOrBeforeMatcher });
|
5,823 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-date.ts | /// <reference types="jest" />
import { isDate } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an instance of `Date`.
* @example
* expect(new Date('2019-12-31')).toBeDate();
*/
toBeDate(): R;
}
interface Expect {
/**
* Asserts that a value is an instance of `Date`.
* @example
* expect(new Date('2019-12-31')).toEqual(
* expect.toBeDate()
* );
*/
toBeDate<T>(): JestMatchers<T>;
}
}
}
export const toBeDateMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () => `expected ${printReceived(value)} to be an instance of Date`,
notMessage: () => `expected ${printReceived(value)} not to be an instance of Date`,
pass: isDate(value),
});
expect.extend({ toBeDate: toBeDateMatcher });
|
5,824 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-decimal-number.ts | /// <reference types="jest" />
import { isDecimalNumber } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is a `Number` with positive decimal places.
* @example
* expect(12.55).toBeDecimalNumber();
*/
toBeDecimalNumber(): R;
}
interface Expect {
/**
* Asserts that a value is a `Number` with positive decimal places.
* @example
* expect(12.55).toEqual(
* expect.toBeDecimalNumber()
* );
*/
toBeDecimalNumber<T>(): JestMatchers<T>;
}
}
}
export const toBeDecimalNumberMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () => `expected ${printReceived(value)} to be a number with positive decimal places`,
notMessage: () =>
`expected ${printReceived(value)} not to be a number with positive decimal places`,
pass: isDecimalNumber(value),
});
expect.extend({ toBeDecimalNumber: toBeDecimalNumberMatcher });
|
5,825 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-divisible-by.ts | /// <reference types="jest" />
import { isDivisibleBy } from 'expect-more';
import { printExpected, printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is a `Number` which results in a whole number when divided by another.
* @example
* expect(12).toBeDivisibleBy(2);
*/
toBeDivisibleBy(other: number): R;
}
interface Expect {
/**
* Asserts that a value is a `Number` which results in a whole number when divided by another.
* @example
* expect(12).toEqual(
* expect.toBeDivisibleBy(2)
* );
*/
toBeDivisibleBy<T>(other: number): JestMatchers<T>;
}
}
}
export const toBeDivisibleByMatcher = (value: unknown, other: number): jest.CustomMatcherResult =>
createResult({
message: () => `expected ${printReceived(value)} to be divisible by ${printExpected(other)}`,
notMessage: () =>
`expected ${printReceived(value)} not to be divisible by ${printExpected(other)}`,
pass: isDivisibleBy(other, value),
});
expect.extend({ toBeDivisibleBy: toBeDivisibleByMatcher });
|
5,826 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-empty-array.ts | /// <reference types="jest" />
import { isEmptyArray } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is a valid `Array` containing no items.
* @example
* expect([]).toBeEmptyArray();
*/
toBeEmptyArray(): R;
}
interface Expect {
/**
* Asserts that a value is a valid `Array` containing no items.
* @example
* expect([]).toEqual(
* expect.toBeEmptyArray()
* );
*/
toBeEmptyArray<T>(): JestMatchers<T>;
}
}
}
export const toBeEmptyArrayMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () => `expected ${printReceived(value)} to be an array containing no items`,
notMessage: () => `expected ${printReceived(value)} not to be an array containing no items`,
pass: isEmptyArray(value),
});
expect.extend({ toBeEmptyArray: toBeEmptyArrayMatcher });
|
5,827 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-empty-object.ts | /// <reference types="jest" />
import { isEmptyObject } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is a valid `Object` containing no instance members.
* @example
* expect({}).toBeEmptyObject();
*/
toBeEmptyObject(): R;
}
interface Expect {
/**
* Asserts that a value is a valid `Object` containing no instance members.
* @example
* expect({}).toEqual(
* expect.toBeEmptyObject()
* );
*/
toBeEmptyObject<T>(): JestMatchers<T>;
}
}
}
export const toBeEmptyObjectMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () => `expected ${printReceived(value)} to be an empty object`,
notMessage: () => `expected ${printReceived(value)} not to be an empty object`,
pass: isEmptyObject(value),
});
expect.extend({ toBeEmptyObject: toBeEmptyObjectMatcher });
|
5,828 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-empty-string.ts | /// <reference types="jest" />
import { isEmptyString } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is a valid `String` containing no characters.
* @example
* expect('').toBeEmptyString();
*/
toBeEmptyString(): R;
}
interface Expect {
/**
* Asserts that a value is a valid `String` containing no characters.
* @example
* expect('').toEqual(
* expect.toBeEmptyString()
* );
*/
toBeEmptyString<T>(): JestMatchers<T>;
}
}
}
export const toBeEmptyStringMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () =>
`expected ${printReceived(value)} to be an empty string or empty instance of String`,
notMessage: () =>
`expected ${printReceived(value)} not to be an empty string or empty instance of String`,
pass: isEmptyString(value),
});
expect.extend({ toBeEmptyString: toBeEmptyStringMatcher });
|
5,829 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-even-number.ts | /// <reference types="jest" />
import { isEvenNumber } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is an even `Number`.
* @example
* expect(2).toBeEvenNumber();
*/
toBeEvenNumber(): R;
}
interface Expect {
/**
* Asserts that a value is an even `Number`.
* @example
* expect(2).toEqual(
* expect.toBeEvenNumber()
* );
*/
toBeEvenNumber<T>(): JestMatchers<T>;
}
}
}
export const toBeEvenNumberMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () => `expected ${printReceived(value)} to be an even number`,
notMessage: () => `expected ${printReceived(value)} not to be an even number`,
pass: isEvenNumber(value),
});
expect.extend({ toBeEvenNumber: toBeEvenNumberMatcher });
|
5,830 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-false.ts | /// <reference types="jest" />
import { isFalse } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is `false` or `new Boolean(false)`.
* @example
* expect(false).toBeFalse();
*/
toBeFalse(): R;
}
interface Expect {
/**
* Asserts that a value is `false` or `new Boolean(false)`.
* @example
* expect(false).toEqual(
* expect.toBeFalse()
* );
*/
toBeFalse<T>(): JestMatchers<T>;
}
}
}
export const toBeFalseMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () => `expected ${printReceived(value)} to be false or Boolean(false)`,
notMessage: () => `expected ${printReceived(value)} not to be false or Boolean(false)`,
pass: isFalse(value),
});
expect.extend({ toBeFalse: toBeFalseMatcher });
|
5,831 | 0 | petrpan-code/JamieMason/expect-more/packages/expect-more-jest | petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-function.ts | /// <reference types="jest" />
import { isFunction } from 'expect-more';
import { printReceived } from 'jest-matcher-utils';
import { createResult } from './lib/create-result';
declare global {
namespace jest {
interface Matchers<R> {
/**
* Asserts that a value is a `Function`.
* @example
* expect(() => 'i am a function').toBeFunction();
*/
toBeFunction(): R;
}
interface Expect {
/**
* Asserts that a value is a `Function`.
* @example
* expect(() => 'i am a function').toEqual(
* expect.toBeFunction()
* );
*/
toBeFunction<T>(): JestMatchers<T>;
}
}
}
export const toBeFunctionMatcher = (value: unknown): jest.CustomMatcherResult =>
createResult({
message: () => `expected ${printReceived(value)} to be a function or async function`,
notMessage: () => `expected ${printReceived(value)} not to be a function or async function`,
pass: isFunction(value),
});
expect.extend({ toBeFunction: toBeFunctionMatcher });
|