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,832
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-generator-function.ts
/// <reference types="jest" /> import { isGeneratorFunction } 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 `yield` syntax. * @example * expect(function* gen() { yield 'i am a generator' }).toBeGeneratorFunction(); */ toBeGeneratorFunction(): R; } interface Expect { /** * Asserts that a value is a `Function` using `yield` syntax. * @example * expect(function* gen() { yield 'i am a generator' }).toEqual( * expect.toBeGeneratorFunction() * ); */ toBeGeneratorFunction<T>(): JestMatchers<T>; } } } export const toBeGeneratorFunctionMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be a function using yield syntax.`, notMessage: () => `expected ${printReceived(value)} not to be a function using yield syntax.`, pass: isGeneratorFunction(value), }); expect.extend({ toBeGeneratorFunction: toBeGeneratorFunctionMatcher });
5,833
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-iso8601.ts
/// <reference types="jest" /> import { isIso8601 } 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 String which conforms to common use-cases of the ISO 8601 standard representation of dates and times. * @example * expect('1999-12-31T23:59:59').toBeIso8601(); */ toBeIso8601(): R; } interface Expect { /** * 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('1999-12-31T23:59:59').toEqual( * expect.toBeIso8601() * ); */ toBeIso8601<T>(): JestMatchers<T>; } } } export const toBeIso8601Matcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be a valid ISO 8601 date string`, notMessage: () => `expected ${printReceived(value)} not to be a valid ISO 8601 date string`, pass: isIso8601(value), }); expect.extend({ toBeIso8601: toBeIso8601Matcher });
5,834
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-json-string.ts
/// <reference types="jest" /> import { isJsonString } 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 `String` of valid JSON. * @example * expect('{"i":"am valid JSON"}').toBeJsonString(); */ toBeJsonString(): R; } interface Expect { /** * Asserts that a value is a `String` of valid JSON. * @example * expect('{"i":"am valid JSON"}').toEqual( * expect.toBeJsonString() * ); */ toBeJsonString<T>(): JestMatchers<T>; } } } export const toBeJsonStringMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be a string of valid JSON`, notMessage: () => `expected ${printReceived(value)} not to be a string of valid JSON`, pass: isJsonString(value), }); expect.extend({ toBeJsonString: toBeJsonStringMatcher });
5,835
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-longer-than.ts
/// <reference types="jest" /> import { isLongerThan } 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 `String` or `Array` whose length is greater than that of another. * @example * expect(['i', 'have', 3]).toBeLongerThan([2, 'items']); */ toBeLongerThan(other: string | any[]): R; } interface Expect { /** * Asserts that a value is a `String` or `Array` whose length is greater than that of another. * @example * expect(['i', 'have', 3]).toEqual( * expect.toBeLongerThan([2, 'items']) * ); */ toBeLongerThan<T>(other: string | any[]): JestMatchers<T>; } } } export const toBeLongerThanMatcher = ( value: unknown, other: string | any[], ): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived( value, )} to be a string or array whose length is greater than that of ${printExpected(other)}`, notMessage: () => `expected ${printReceived( value, )} not to be a string or array whose length is greater than that of ${printExpected(other)}`, pass: isLongerThan(other, value), }); expect.extend({ toBeLongerThan: toBeLongerThanMatcher });
5,836
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-negative-number.ts
/// <reference types="jest" /> import { isNegativeNumber } 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` less than 0. * @example * expect(-18).toBeNegativeNumber(); */ toBeNegativeNumber(): R; } interface Expect { /** * Asserts that a value is a `Number` less than 0. * @example * expect(-18).toEqual( * expect.toBeNegativeNumber() * ); */ toBeNegativeNumber<T>(): JestMatchers<T>; } } } export const toBeNegativeNumberMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be a negative number`, notMessage: () => `expected ${printReceived(value)} not to be a negative number`, pass: isNegativeNumber(value), }); expect.extend({ toBeNegativeNumber: toBeNegativeNumberMatcher });
5,837
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-nil.ts
/// <reference types="jest" /> import { isNil } 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 `null` or `undefined` * @example * expect(undefined).toBeNil(); */ toBeNil(): R; } interface Expect { /** * Asserts that a value is `null` or `undefined` * @example * expect(undefined).toEqual( * expect.toBeNil() * ); */ toBeNil<T>(): JestMatchers<T>; } } } export const toBeNilMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be null or undefined`, notMessage: () => `expected ${printReceived(value)} not to be null or undefined`, pass: isNil(value), }); expect.extend({ toBeNil: toBeNilMatcher });
5,838
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-non-empty-array.ts
/// <reference types="jest" /> import { isNonEmptyArray } 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 at least one value. * @example * expect(['i', 'am not empty']).toBeNonEmptyArray(); */ toBeNonEmptyArray(): R; } interface Expect { /** * Asserts that a value is an `Array` containing at least one value. * @example * expect(['i', 'am not empty']).toEqual( * expect.toBeNonEmptyArray() * ); */ toBeNonEmptyArray<T>(): JestMatchers<T>; } } } export const toBeNonEmptyArrayMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be an array with at least one item`, notMessage: () => `expected ${printReceived(value)} not to be an array with at least one item`, pass: isNonEmptyArray(value), }); expect.extend({ toBeNonEmptyArray: toBeNonEmptyArrayMatcher });
5,839
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-non-empty-object.ts
/// <reference types="jest" /> import { isNonEmptyObject } 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 `Object` containing at least one own member. * @example * expect({ i: 'am not empty' }).toBeNonEmptyObject(); */ toBeNonEmptyObject(): R; } interface Expect { /** * Asserts that a value is an `Object` containing at least one own member. * @example * expect({ i: 'am not empty' }).toEqual( * expect.toBeNonEmptyObject() * ); */ toBeNonEmptyObject<T>(): JestMatchers<T>; } } } export const toBeNonEmptyObjectMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be an object with at least one own member`, notMessage: () => `expected ${printReceived(value)} not to be an object with at least one own member`, pass: isNonEmptyObject(value), }); expect.extend({ toBeNonEmptyObject: toBeNonEmptyObjectMatcher });
5,840
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-non-empty-string.ts
/// <reference types="jest" /> import { isNonEmptyString } 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 at least one character. * @example * expect('i am not empty').toBeNonEmptyString(); */ toBeNonEmptyString(): R; } interface Expect { /** * Asserts that a value is a valid `String` containing at least one character. * @example * expect('i am not empty').toEqual( * expect.toBeNonEmptyString() * ); */ toBeNonEmptyString<T>(): JestMatchers<T>; } } } export const toBeNonEmptyStringMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be a string with at least one character`, notMessage: () => `expected ${printReceived(value)} not to be a string with at least one character`, pass: isNonEmptyString(value), }); expect.extend({ toBeNonEmptyString: toBeNonEmptyStringMatcher });
5,841
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-nullable-of.ts
import { equals } from '@jest/expect-utils'; import { isNull } 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 equal to ${other} or null. * @example * expect({ x: 12, y: 22 }).toBeNullableOf({ * x: expect.toBeNumber(), * y: expect.toBeNumber(), * }); * expect(null).toBeNullableOf({ * x: expect.toBeNumber(), * y: expect.toBeNumber(), * }); */ toBeNullableOf(other: unknown): R; } interface Expect { /** * Asserts that a value is equal to ${other} or null. * @example * expect({ x: 12, y: 22 }).toEqual( * expect.toBeNullableOf({ * x: expect.toBeNumber(), * y: expect.toBeNumber() * }) * ); * expect(null).toEqual( * expect.toBeNullableOf({ * x: expect.toBeNumber(), * y: expect.toBeNumber() * }) * ); */ toBeNullableOf<T>(other: unknown): JestMatchers<T>; } } } export const toBeNullableOfMatcher = (value: unknown, other: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to equal ${printExpected(other)} or ${printExpected(null)}`, notMessage: () => `expected ${printReceived(value)} not to equal ${printExpected(other)} or ${printExpected( null, )}`, pass: isNull(value) || equals(value, other), }); expect.extend({ toBeNullableOf: toBeNullableOfMatcher });
5,842
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-number.ts
/// <reference types="jest" /> import { isNumber } 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 `Number` or `new Number()` and not `NaN`. * @example * expect(8).toBeNumber(); */ toBeNumber(): R; } interface Expect { /** * Asserts that a value is a valid `Number` or `new Number()` and not `NaN`. * @example * expect(8).toEqual( * expect.toBeNumber() * ); */ toBeNumber<T>(): JestMatchers<T>; } } } export const toBeNumberMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be a valid number`, notMessage: () => `expected ${printReceived(value)} not to be a valid number`, pass: isNumber(value), }); expect.extend({ toBeNumber: toBeNumberMatcher });
5,843
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-object.ts
/// <reference types="jest" /> import { isObject } 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 `Object`. * @example * expect({}).toBeObject(); */ toBeObject(): R; } interface Expect { /** * Asserts that a value is an `Object`. * @example * expect({}).toEqual( * expect.toBeObject() * ); */ toBeObject<T>(): JestMatchers<T>; } } } export const toBeObjectMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be an object`, notMessage: () => `expected ${printReceived(value)} not to be an object`, pass: isObject(value), }); expect.extend({ toBeObject: toBeObjectMatcher });
5,844
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-odd-number.ts
/// <reference types="jest" /> import { isOddNumber } 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 odd `Number`. * @example * expect(5).toBeOddNumber(); */ toBeOddNumber(): R; } interface Expect { /** * Asserts that a value is an odd `Number`. * @example * expect(5).toEqual( * expect.toBeOddNumber() * ); */ toBeOddNumber<T>(): JestMatchers<T>; } } } export const toBeOddNumberMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be an odd number`, notMessage: () => `expected ${printReceived(value)} not to be an odd number`, pass: isOddNumber(value), }); expect.extend({ toBeOddNumber: toBeOddNumberMatcher });
5,845
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-optional-of.ts
import { equals } from '@jest/expect-utils'; import { isUndefined } 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 equal to ${other} or undefined. * @example * expect({ x: 12, y: 22 }).toBeOptionalOf({ * x: expect.toBeNumber(), * y: expect.toBeNumber(), * }); * expect(undefined).toBeOptionalOf({ * x: expect.toBeNumber(), * y: expect.toBeNumber(), * }); */ toBeOptionalOf(other: unknown): R; } interface Expect { /** * Asserts that a value is equal to ${other} or undefined. * @example * expect({ x: 12, y: 22 }).toEqual( * expect.toBeOptionalOf({ * x: expect.toBeNumber(), * y: expect.toBeNumber() * }) * ); * expect(undefined).toEqual( * expect.toBeOptionalOf({ * x: expect.toBeNumber(), * y: expect.toBeNumber() * }) * ); */ toBeOptionalOf<T>(other: unknown): JestMatchers<T>; } } } export const toBeOptionalOfMatcher = (value: unknown, other: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to equal ${printExpected(other)} or ${printExpected( undefined, )}`, notMessage: () => `expected ${printReceived(value)} not to equal ${printExpected(other)} or ${printExpected( undefined, )}`, pass: isUndefined(value) || equals(value, other), }); expect.extend({ toBeOptionalOf: toBeOptionalOfMatcher });
5,846
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-positive-number.ts
/// <reference types="jest" /> import { isPositiveNumber } 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` greater than 0. * @example * expect(5).toBePositiveNumber(); */ toBePositiveNumber(): R; } interface Expect { /** * Asserts that a value is a `Number` greater than 0. * @example * expect(5).toEqual( * expect.toBePositiveNumber() * ); */ toBePositiveNumber<T>(): JestMatchers<T>; } } } export const toBePositiveNumberMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be a positive number`, notMessage: () => `expected ${printReceived(value)} not to be a positive number`, pass: isPositiveNumber(value), }); expect.extend({ toBePositiveNumber: toBePositiveNumberMatcher });
5,847
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-reg-exp.ts
/// <reference types="jest" /> import { isRegExp } 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 `RegExp`. * @example * expect(new RegExp('i am a regular expression')).toBeRegExp(); */ toBeRegExp(): R; } interface Expect { /** * Asserts that a value is a `RegExp`. * @example * expect(new RegExp('i am a regular expression')).toEqual( * expect.toBeRegExp() * ); */ toBeRegExp<T>(): JestMatchers<T>; } } } export const toBeRegExpMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be a regular expression`, notMessage: () => `expected ${printReceived(value)} not to be a regular expression`, pass: isRegExp(value), }); expect.extend({ toBeRegExp: toBeRegExpMatcher });
5,848
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-same-length-as.ts
/// <reference types="jest" /> import { isSameLengthAs } 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 `String` or `Array` whose length is the same as that of the other provided. * @example * expect(['i also have', '2 items']).toBeSameLengthAs(['i have', '2 items']); */ toBeSameLengthAs(other: string | any[]): R; } interface Expect { /** * Asserts that a value is a `String` or `Array` whose length is the same as that of the other provided. * @example * expect(['i also have', '2 items']).toEqual( * expect.toBeSameLengthAs(['i have', '2 items']) * ); */ toBeSameLengthAs<T>(other: string | any[]): JestMatchers<T>; } } } export const toBeSameLengthAsMatcher = ( value: unknown, other: string | any[], ): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived( value, )} to be a string or array whose length is the same as that of ${printExpected(other)}`, notMessage: () => `expected ${printReceived( value, )} not to be a string or array whose length is the same as that of ${printExpected(other)}`, pass: isSameLengthAs(other, value), }); expect.extend({ toBeSameLengthAs: toBeSameLengthAsMatcher });
5,849
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-shorter-than.ts
/// <reference types="jest" /> import { isShorterThan } 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 `String` or `Array` whose length is less than that of the other provided. * @example * expect(['i have one item']).toBeShorterThan(['i', 'have', 4, 'items']); */ toBeShorterThan(other: string | any[]): R; } interface Expect { /** * Asserts that a value is a `String` or `Array` whose length is less than that of the other provided. * @example * expect(['i have one item']).toEqual( * expect.toBeShorterThan(['i', 'have', 4, 'items']) * ); */ toBeShorterThan<T>(other: string | any[]): JestMatchers<T>; } } } export const toBeShorterThanMatcher = ( value: unknown, other: string | any[], ): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived( value, )} to be a string or array whose length is less than that of ${printExpected(other)}`, notMessage: () => `expected ${printReceived( value, )} not to be a string or array whose length is less than that of ${printExpected(other)}`, pass: isShorterThan(other, value), }); expect.extend({ toBeShorterThan: toBeShorterThanMatcher });
5,850
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-string.ts
/// <reference types="jest" /> import { isString } 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 `String` or `new String()`. * @example * expect('i am a string').toBeString(); */ toBeString(): R; } interface Expect { /** * Asserts that a value is a `String` or `new String()`. * @example * expect('i am a string').toEqual( * expect.toBeString() * ); */ toBeString<T>(): JestMatchers<T>; } } } export const toBeStringMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be a string`, notMessage: () => `expected ${printReceived(value)} not to be a string`, pass: isString(value), }); expect.extend({ toBeString: toBeStringMatcher });
5,851
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-true.ts
/// <reference types="jest" /> import { isTrue } 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` or `new Boolean(true)`. * @example * expect(true).toBeTrue(); */ toBeTrue(): R; } interface Expect { /** * Asserts that a value is `true` or `new Boolean(true)`. * @example * expect(true).toEqual( * expect.toBeTrue() * ); */ toBeTrue<T>(): JestMatchers<T>; } } } export const toBeTrueMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be true or Boolean(true)`, notMessage: () => `expected ${printReceived(value)} not to be true or Boolean(true)`, pass: isTrue(value), }); expect.extend({ toBeTrue: toBeTrueMatcher });
5,852
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-valid-date.ts
/// <reference types="jest" /> import { isValidDate } 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` 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(new Date('2020-01-01')).toBeValidDate(); */ toBeValidDate(): R; } interface Expect { /** * 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(new Date('2020-01-01')).toEqual( * expect.toBeValidDate() * ); */ toBeValidDate<T>(): JestMatchers<T>; } } } export const toBeValidDateMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be an instance of Date with a valid value`, notMessage: () => `expected ${printReceived(value)} not to be an instance of Date with a valid value`, pass: isValidDate(value), }); expect.extend({ toBeValidDate: toBeValidDateMatcher });
5,853
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-visible-string.ts
/// <reference types="jest" /> import { isVisibleString } 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 at least one character which is not whitespace. * @example * expect('i am visible').toBeVisibleString(); */ toBeVisibleString(): R; } interface Expect { /** * Asserts that a value is a valid `String` containing at least one character which is not whitespace. * @example * expect('i am visible').toEqual( * expect.toBeVisibleString() * ); */ toBeVisibleString<T>(): JestMatchers<T>; } } } export const toBeVisibleStringMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be a string with at least one non-whitespace character`, notMessage: () => `expected ${printReceived( value, )} not to be a string with at least one non-whitespace character`, pass: isVisibleString(value), }); expect.extend({ toBeVisibleString: toBeVisibleStringMatcher });
5,854
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-walkable.ts
/// <reference types="jest" /> import { isWalkable } 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 safe to attempt to read property values from. * @example * expect({}).toBeWalkable(); */ toBeWalkable(): R; } interface Expect { /** * Asserts that a value is safe to attempt to read property values from. * @example * expect({}).toEqual( * expect.toBeWalkable() * ); */ toBeWalkable<T>(): JestMatchers<T>; } } } export const toBeWalkableMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be walkable`, notMessage: () => `expected ${printReceived(value)} not to be walkable`, pass: isWalkable(value), }); expect.extend({ toBeWalkable: toBeWalkableMatcher });
5,855
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-whitespace.ts
/// <reference types="jest" /> import { isWhitespace } 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 `String` containing only whitespace characters. * @example * expect(' ').toBeWhitespace(); */ toBeWhitespace(): R; } interface Expect { /** * Asserts that a value is a `String` containing only whitespace characters. * @example * expect(' ').toEqual( * expect.toBeWhitespace() * ); */ toBeWhitespace<T>(): JestMatchers<T>; } } } export const toBeWhitespaceMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be a string containing only whitespace characters`, notMessage: () => `expected ${printReceived(value)} not to be a string containing only whitespace characters`, pass: isWhitespace(value), }); expect.extend({ toBeWhitespace: toBeWhitespaceMatcher });
5,856
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-whole-number.ts
/// <reference types="jest" /> import { isWholeNumber } 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 no positive decimal places. * @example * expect(8).toBeWholeNumber(); */ toBeWholeNumber(): R; } interface Expect { /** * Asserts that a value is a `Number` with no positive decimal places. * @example * expect(8).toEqual( * expect.toBeWholeNumber() * ); */ toBeWholeNumber<T>(): JestMatchers<T>; } } } export const toBeWholeNumberMatcher = (value: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be a whole number`, notMessage: () => `expected ${printReceived(value)} not to be a whole number`, pass: isWholeNumber(value), }); expect.extend({ toBeWholeNumber: toBeWholeNumberMatcher });
5,857
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-be-within-range.ts
/// <reference types="jest" /> import { isWithinRange } 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 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): R; } interface Expect { /** * 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).toEqual( * expect.toBeWithinRange(0, 10) * ); */ toBeWithinRange<T>(floor: number, ceiling: number): JestMatchers<T>; } } } export const toBeWithinRangeMatcher = ( value: unknown, floor: number, ceiling: number, ): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to be greater than or equal to ${printExpected( floor, )} and less than or equal to ${printExpected(ceiling)}`, notMessage: () => `expected ${printReceived(value)} not to be greater than or equal to ${printExpected( floor, )} and less than or equal to ${printExpected(ceiling)}`, pass: isWithinRange(floor, ceiling, value), }); expect.extend({ toBeWithinRange: toBeWithinRangeMatcher });
5,858
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-end-with.ts
/// <reference types="jest" /> import { endsWith } 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 a string whose trailing characters are equal to those of the provided string. * @example * expect('JavaScript').toEndWith('Script'); */ toEndWith(otherString: unknown): R; } interface Expect { /** * Asserts that value is a string whose trailing characters are equal to those of the provided string. * @example * expect('JavaScript').toEqual( * expect.toEndWith('Script') * ); */ toEndWith<T>(otherString: unknown): JestMatchers<T>; } } } export const toEndWithMatcher = (value: unknown, otherString: unknown): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to end with ${printExpected(otherString)}`, notMessage: () => `expected ${printReceived(value)} not to end with ${printExpected(otherString)}`, pass: endsWith(otherString, value), }); expect.extend({ toEndWith: toEndWithMatcher });
5,859
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/to-start-with.ts
/// <reference types="jest" /> import { startsWith } 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 a string whose trailing characters are equal to those of the provided string. * @example * expect('JavaScript').toStartWith('Java'); */ toStartWith(otherString: string): R; } interface Expect { /** * Asserts that value is a string whose trailing characters are equal to those of the provided string. * @example * expect('JavaScript').toEqual( * expect.toStartWith('Java') * ); */ toStartWith<T>(otherString: string): JestMatchers<T>; } } } export const toStartWithMatcher = (value: unknown, otherString: string): jest.CustomMatcherResult => createResult({ message: () => `expected ${printReceived(value)} to start with ${printExpected(otherString)}`, notMessage: () => `expected ${printReceived(value)} not to start with ${printExpected(otherString)}`, pass: startsWith(otherString, value), }); expect.extend({ toStartWith: toStartWithMatcher });
5,860
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/src/lib/create-result.ts
export const createResult = ({ pass, message, notMessage, }: { pass: boolean; message: () => string; notMessage: () => string; }): jest.CustomMatcherResult => ({ message: () => (pass ? notMessage() : message()).trim(), pass, });
5,862
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/issue-35.spec.ts
import 'expect-more-jest'; describe('when a test subject contains an object with no prototype', () => { describe('when the test fails (array has 1 item not 8)', () => { it('should construct matcher test failure messages correctly', () => { try { expect.assertions(3); expect([Object.create(null)]).toBeArrayOfSize(8); } catch (err) { expect(err.message).toContain('to be an array containing exactly'); expect(err.message).not.toContain('Cannot convert object to primitive value'); } }); }); });
5,863
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-after.spec.ts
import 'expect-more-jest'; it('provides expect().toBeAfter()', () => { expect(new Date('2020-01-01')).toBeAfter(new Date('2019-12-31')); }); it('provides expect().not.toBeAfter()', () => { expect(() => expect(new Date('2020-01-01')).not.toBeAfter(new Date('2019-12-31'))).toThrow(); }); it('provides expect.toBeAfter()', () => { expect(new Date('2020-01-01')).toEqual(expect.toBeAfter(new Date('2019-12-31'))); });
5,864
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-array-including-all-of.spec.ts
import 'expect-more-jest'; it('provides expect().toBeArrayIncludingAllOf()', () => { expect([12, 0, 14, 'Ivo']).toBeArrayIncludingAllOf(['Ivo', 14]); }); it('provides expect().not.toBeArrayIncludingAllOf()', () => { expect(() => expect([12, 0, 14, 'Ivo']).not.toBeArrayIncludingAllOf(['Ivo', 14])).toThrow(); }); it('provides expect.toBeArrayIncludingAllOf()', () => { expect([12, 0, 14, 'Ivo']).toEqual(expect.toBeArrayIncludingAllOf(['Ivo', 14])); });
5,865
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-array-including-any-of.spec.ts
import 'expect-more-jest'; it('provides expect().toBeArrayIncludingAnyOf()', () => { expect([12, 0, 14, 'Ginola']).toBeArrayIncludingAnyOf(['Ginola', 3]); }); it('provides expect().not.toBeArrayIncludingAnyOf()', () => { expect(() => expect([12, 0, 14, 'Ginola']).not.toBeArrayIncludingAnyOf(['Ginola', 3])).toThrow(); }); it('provides expect.toBeArrayIncludingAnyOf()', () => { expect([12, 0, 14, 'Ginola']).toEqual(expect.toBeArrayIncludingAnyOf(['Ginola', 3])); });
5,866
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-array-including-only.spec.ts
import 'expect-more-jest'; it('provides expect().toBeArrayIncludingOnly()', () => { expect([5, 10, 1]).toBeArrayIncludingOnly([1, 5, 10]); }); it('provides expect().not.toBeArrayIncludingOnly()', () => { expect(() => expect([5, 10, 1]).not.toBeArrayIncludingOnly([1, 5, 10])).toThrow(); }); it('provides expect.toBeArrayIncludingOnly()', () => { expect([5, 10, 1]).toEqual(expect.toBeArrayIncludingOnly([1, 5, 10])); });
5,867
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-array-of-booleans.spec.ts
import 'expect-more-jest'; it('provides expect().toBeArrayOfBooleans()', () => { expect([true, false, new Boolean(true)]).toBeArrayOfBooleans(); }); it('provides expect().not.toBeArrayOfBooleans()', () => { expect(() => expect([true, false, new Boolean(true)]).not.toBeArrayOfBooleans()).toThrow(); }); it('provides expect.toBeArrayOfBooleans()', () => { expect([true, false, new Boolean(true)]).toEqual(expect.toBeArrayOfBooleans()); });
5,868
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-array-of-numbers.spec.ts
import 'expect-more-jest'; it('provides expect().toBeArrayOfNumbers()', () => { expect([12, 0, 14]).toBeArrayOfNumbers(); }); it('provides expect().not.toBeArrayOfNumbers()', () => { expect(() => expect([12, 0, 14]).not.toBeArrayOfNumbers()).toThrow(); }); it('provides expect.toBeArrayOfNumbers()', () => { expect([12, 0, 14]).toEqual(expect.toBeArrayOfNumbers()); });
5,869
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-array-of-objects.spec.ts
import 'expect-more-jest'; it('provides expect().toBeArrayOfObjects()', () => { expect([{}, new Object()]).toBeArrayOfObjects(); }); it('provides expect().not.toBeArrayOfObjects()', () => { expect(() => expect([{}, new Object()]).not.toBeArrayOfObjects()).toThrow(); }); it('provides expect.toBeArrayOfObjects()', () => { expect([{}, new Object()]).toEqual(expect.toBeArrayOfObjects()); });
5,870
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-array-of-size.spec.ts
import 'expect-more-jest'; it('provides expect().toBeArrayOfSize()', () => { expect(['i', 'contain', 4, 'items']).toBeArrayOfSize(4); }); it('provides expect().not.toBeArrayOfSize()', () => { expect(() => expect(['i', 'contain', 4, 'items']).not.toBeArrayOfSize(4)).toThrow(); }); it('provides expect.toBeArrayOfSize()', () => { expect(['i', 'contain', 4, 'items']).toEqual(expect.toBeArrayOfSize(4)); });
5,871
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-array-of-strings.spec.ts
import 'expect-more-jest'; it('provides expect().toBeArrayOfStrings()', () => { expect(['we', 'are', 'all', 'strings']).toBeArrayOfStrings(); }); it('provides expect().not.toBeArrayOfStrings()', () => { expect(() => expect(['we', 'are', 'all', 'strings']).not.toBeArrayOfStrings()).toThrow(); }); it('provides expect.toBeArrayOfStrings()', () => { expect(['we', 'are', 'all', 'strings']).toEqual(expect.toBeArrayOfStrings()); });
5,872
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-array-of.spec.ts
import 'expect-more-jest'; it('provides expect().toBeArrayOf()', () => { expect([ { name: 'Guybrush', age: 20 }, { name: 'Elaine', age: 22 }, ]).toBeArrayOf({ name: expect.toBeNonEmptyString(), age: expect.toBeWithinRange(20, 30), }); }); it('provides expect().not.toBeArrayOf()', () => { expect([true, false, 'i am not a boolean']).not.toBeArrayOf(expect.toBeBoolean()); expect(() => expect([{ name: 'Guybrush' }, { name: 'Elaine' }]).not.toBeArrayOf({ name: expect.toBeNonEmptyString(), }), ).toThrow(); }); it('provides expect.toBeArrayOf()', () => { expect([{ name: 'Guybrush' }, { name: 'Elaine' }]).toEqual( expect.toBeArrayOf({ name: expect.toBeNonEmptyString() }), ); });
5,873
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-array.spec.ts
import 'expect-more-jest'; it('provides expect().toBeArray()', () => { expect([2, true, 'string']).toBeArray(); }); it('provides expect().not.toBeArray()', () => { expect(() => expect([2, true, 'string']).not.toBeArray()).toThrow(); }); it('provides expect.toBeArray()', () => { expect([2, true, 'string']).toEqual(expect.toBeArray()); });
5,874
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-async-function.spec.ts
import 'expect-more-jest'; // eval is workaround for typescript converting async to non-async it('provides expect().toBeAsyncFunction()', () => { expect(eval('(async (_) => _)')).toBeAsyncFunction(); }); it('provides expect().not.toBeAsyncFunction()', () => { expect(() => expect(eval('(async (_) => _)')).not.toBeAsyncFunction()).toThrow(); }); it('provides expect.toBeAsyncFunction()', () => { expect(eval('(async (_) => _)')).toEqual(expect.toBeAsyncFunction()); });
5,875
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-before.spec.ts
import 'expect-more-jest'; it('provides expect().toBeBefore()', () => { expect(new Date('2019-12-31')).toBeBefore(new Date('2020-01-01')); }); it('provides expect().not.toBeBefore()', () => { expect(() => expect(new Date('2019-12-31')).not.toBeBefore(new Date('2020-01-01'))).toThrow(); }); it('provides expect.toBeBefore()', () => { expect(new Date('2019-12-31')).toEqual(expect.toBeBefore(new Date('2020-01-01'))); });
5,876
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-boolean.spec.ts
import 'expect-more-jest'; it('provides expect().toBeBoolean()', () => { expect(false).toBeBoolean(); }); it('provides expect().not.toBeBoolean()', () => { expect(() => expect(false).not.toBeBoolean()).toThrow(); }); it('provides expect.toBeBoolean()', () => { expect(false).toEqual(expect.toBeBoolean()); });
5,877
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-calculable.spec.ts
import 'expect-more-jest'; it('provides expect().toBeCalculable()', () => { expect('100').toBeCalculable(); }); it('provides expect().not.toBeCalculable()', () => { expect(() => expect('100').not.toBeCalculable()).toThrow(); }); it('provides expect.toBeCalculable()', () => { expect('100').toEqual(expect.toBeCalculable()); });
5,878
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-date-between.spec.ts
import 'expect-more-jest'; it('provides expect().toBeDateBetween()', () => { expect(new Date('2019-12-11')).toBeDateBetween(new Date('2019-12-10'), new Date('2019-12-12')); }); it('provides expect().not.toBeDateBetween()', () => { expect(() => expect(new Date('2019-12-11')).not.toBeDateBetween( new Date('2019-12-10'), new Date('2019-12-12'), ), ).toThrow(); }); it('provides expect.toBeDateBetween()', () => { expect(new Date('2019-12-11')).toEqual( expect.toBeDateBetween(new Date('2019-12-10'), new Date('2019-12-12')), ); });
5,879
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-date-in-month.spec.ts
import 'expect-more-jest'; it('provides expect().toBeDateInMonth()', () => { expect(new Date('2021-08-29')).toBeDateInMonth(7); }); it('provides expect().not.toBeDateInMonth()', () => { expect(() => expect(new Date('2021-08-29')).not.toBeDateInMonth(7)).toThrow(); }); it('provides expect.toBeDateInMonth()', () => { expect(new Date('2021-08-29')).toEqual(expect.toBeDateInMonth(7)); });
5,880
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-date-in-year.spec.ts
import 'expect-more-jest'; it('provides expect().toBeDateInYear()', () => { expect(new Date('2021-08-29')).toBeDateInYear(2021); }); it('provides expect().not.toBeDateInYear()', () => { expect(() => expect(new Date('2021-08-29')).not.toBeDateInYear(2021)).toThrow(); }); it('provides expect.toBeDateInYear()', () => { expect(new Date('2021-08-29')).toEqual(expect.toBeDateInYear(2021)); });
5,881
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-date-on-day-of-month.spec.ts
import 'expect-more-jest'; it('provides expect().toBeDateOnDayOfMonth()', () => { expect(new Date('2021-08-29')).toBeDateOnDayOfMonth(29); }); it('provides expect().not.toBeDateOnDayOfMonth()', () => { expect(() => expect(new Date('2021-08-29')).not.toBeDateOnDayOfMonth(29)).toThrow(); }); it('provides expect.toBeDateOnDayOfMonth()', () => { expect(new Date('2021-08-29')).toEqual(expect.toBeDateOnDayOfMonth(29)); });
5,882
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-date-on-day-of-week.spec.ts
import 'expect-more-jest'; it('provides expect().toBeDateOnDayOfWeek()', () => { expect(new Date('2021-08-29')).toBeDateOnDayOfWeek(0); }); it('provides expect().not.toBeDateOnDayOfWeek()', () => { expect(() => expect(new Date('2021-08-29')).not.toBeDateOnDayOfWeek(0)).toThrow(); }); it('provides expect.toBeDateOnDayOfWeek()', () => { expect(new Date('2021-08-29')).toEqual(expect.toBeDateOnDayOfWeek(0)); });
5,883
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-date-on-or-after.spec.ts
import 'expect-more-jest'; it('provides expect().toBeDateOnOrAfter()', () => { expect(new Date('2019-12-31')).toBeDateOnOrAfter(new Date('2019-12-15')); }); it('provides expect().not.toBeDateOnOrAfter()', () => { expect(() => expect(new Date('2019-12-31')).not.toBeDateOnOrAfter(new Date('2019-12-15')), ).toThrow(); }); it('provides expect.toBeDateOnOrAfter()', () => { expect(new Date('2019-12-31')).toEqual(expect.toBeDateOnOrAfter(new Date('2019-12-15'))); });
5,884
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-date-on-or-before.spec.ts
import 'expect-more-jest'; it('provides expect().toBeDateOnOrBefore()', () => { expect(new Date('2019-12-15')).toBeDateOnOrBefore(new Date('2019-12-31')); }); it('provides expect().not.toBeDateOnOrBefore()', () => { expect(() => expect(new Date('2019-12-15')).not.toBeDateOnOrBefore(new Date('2019-12-31')), ).toThrow(); }); it('provides expect.toBeDateOnOrBefore()', () => { expect(new Date('2019-12-15')).toEqual(expect.toBeDateOnOrBefore(new Date('2019-12-31'))); });
5,885
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-date.spec.ts
import 'expect-more-jest'; it('provides expect().toBeDate()', () => { expect(new Date('2019-12-31')).toBeDate(); }); it('provides expect().not.toBeDate()', () => { expect(() => expect(new Date('2019-12-31')).not.toBeDate()).toThrow(); }); it('provides expect.toBeDate()', () => { expect(new Date('2019-12-31')).toEqual(expect.toBeDate()); });
5,886
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-decimal-number.spec.ts
import 'expect-more-jest'; it('provides expect().toBeDecimalNumber()', () => { expect(12.55).toBeDecimalNumber(); }); it('provides expect().not.toBeDecimalNumber()', () => { expect(() => expect(12.55).not.toBeDecimalNumber()).toThrow(); }); it('provides expect.toBeDecimalNumber()', () => { expect(12.55).toEqual(expect.toBeDecimalNumber()); });
5,887
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-divisible-by.spec.ts
import 'expect-more-jest'; it('provides expect().toBeDivisibleBy()', () => { expect(12).toBeDivisibleBy(2); }); it('provides expect().not.toBeDivisibleBy()', () => { expect(() => expect(12).not.toBeDivisibleBy(2)).toThrow(); }); it('provides expect.toBeDivisibleBy()', () => { expect(12).toEqual(expect.toBeDivisibleBy(2)); });
5,888
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-empty-array.spec.ts
import 'expect-more-jest'; it('provides expect().toBeEmptyArray()', () => { expect([]).toBeEmptyArray(); }); it('provides expect().not.toBeEmptyArray()', () => { expect(() => expect([]).not.toBeEmptyArray()).toThrow(); }); it('provides expect.toBeEmptyArray()', () => { expect([]).toEqual(expect.toBeEmptyArray()); });
5,889
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-empty-object.spec.ts
import 'expect-more-jest'; it('provides expect().toBeEmptyObject()', () => { expect({}).toBeEmptyObject(); }); it('provides expect().not.toBeEmptyObject()', () => { expect(() => expect({}).not.toBeEmptyObject()).toThrow(); }); it('provides expect.toBeEmptyObject()', () => { expect({}).toEqual(expect.toBeEmptyObject()); });
5,890
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-empty-string.spec.ts
import 'expect-more-jest'; it('provides expect().toBeEmptyString()', () => { expect('').toBeEmptyString(); }); it('provides expect().not.toBeEmptyString()', () => { expect(() => expect('').not.toBeEmptyString()).toThrow(); }); it('provides expect.toBeEmptyString()', () => { expect('').toEqual(expect.toBeEmptyString()); });
5,891
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-even-number.spec.ts
import 'expect-more-jest'; it('provides expect().toBeEvenNumber()', () => { expect(2).toBeEvenNumber(); }); it('provides expect().not.toBeEvenNumber()', () => { expect(() => expect(2).not.toBeEvenNumber()).toThrow(); }); it('provides expect.toBeEvenNumber()', () => { expect(2).toEqual(expect.toBeEvenNumber()); });
5,892
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-false.spec.ts
import 'expect-more-jest'; it('provides expect().toBeFalse()', () => { expect(false).toBeFalse(); }); it('provides expect().not.toBeFalse()', () => { expect(() => expect(false).not.toBeFalse()).toThrow(); }); it('provides expect.toBeFalse()', () => { expect(false).toEqual(expect.toBeFalse()); });
5,893
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-function.spec.ts
import 'expect-more-jest'; it('provides expect().toBeFunction()', () => { expect(() => 'i am a function').toBeFunction(); }); it('provides expect().not.toBeFunction()', () => { expect(() => expect(() => 'i am a function').not.toBeFunction()).toThrow(); }); it('provides expect.toBeFunction()', () => { expect(() => 'i am a function').toEqual(expect.toBeFunction()); });
5,894
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-generator-function.spec.ts
import 'expect-more-jest'; // eval is workaround for typescript converting generator fns it('provides expect().toBeGeneratorFunction()', () => { expect(eval('(function*() {yield 2;})')).toBeGeneratorFunction(); }); it('provides expect().not.toBeGeneratorFunction()', () => { expect(() => expect(eval('(function*() {yield 2;})')).not.toBeGeneratorFunction()).toThrow(); }); it('provides expect.toBeGeneratorFunction()', () => { expect(eval('(function*() {yield 2;})')).toEqual(expect.toBeGeneratorFunction()); });
5,895
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-iso8601.spec.ts
import 'expect-more-jest'; it('provides expect().toBeIso8601()', () => { expect('1999-12-31T23:59:59').toBeIso8601(); }); it('provides expect().not.toBeIso8601()', () => { expect(() => expect('1999-12-31T23:59:59').not.toBeIso8601()).toThrow(); }); it('provides expect.toBeIso8601()', () => { expect('1999-12-31T23:59:59').toEqual(expect.toBeIso8601()); });
5,896
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-json-string.spec.ts
import 'expect-more-jest'; it('provides expect().toBeJsonString()', () => { expect('{"i":"am valid JSON"}').toBeJsonString(); }); it('provides expect().not.toBeJsonString()', () => { expect(() => expect('{"i":"am valid JSON"}').not.toBeJsonString()).toThrow(); }); it('provides expect.toBeJsonString()', () => { expect('{"i":"am valid JSON"}').toEqual(expect.toBeJsonString()); });
5,897
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-longer-than.spec.ts
import 'expect-more-jest'; it('provides expect().toBeLongerThan()', () => { expect(['i', 'have', 3]).toBeLongerThan([2, 'items']); }); it('provides expect().not.toBeLongerThan()', () => { expect(() => expect(['i', 'have', 3]).not.toBeLongerThan([2, 'items'])).toThrow(); }); it('provides expect.toBeLongerThan()', () => { expect(['i', 'have', 3]).toEqual(expect.toBeLongerThan([2, 'items'])); });
5,898
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-negative-number.spec.ts
import 'expect-more-jest'; it('provides expect().toBeNegativeNumber()', () => { expect(-18).toBeNegativeNumber(); }); it('provides expect().not.toBeNegativeNumber()', () => { expect(() => expect(-18).not.toBeNegativeNumber()).toThrow(); }); it('provides expect.toBeNegativeNumber()', () => { expect(-18).toEqual(expect.toBeNegativeNumber()); });
5,899
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-nil.spec.ts
import 'expect-more-jest'; it('provides expect().toBeNil()', () => { expect(undefined).toBeNil(); }); it('provides expect().not.toBeNil()', () => { expect(() => expect(undefined).not.toBeNil()).toThrow(); }); it('provides expect.toBeNil()', () => { expect(undefined).toEqual(expect.toBeNil()); });
5,900
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-non-empty-array.spec.ts
import 'expect-more-jest'; it('provides expect().toBeNonEmptyArray()', () => { expect(['i', 'am not empty']).toBeNonEmptyArray(); }); it('provides expect().not.toBeNonEmptyArray()', () => { expect(() => expect(['i', 'am not empty']).not.toBeNonEmptyArray()).toThrow(); }); it('provides expect.toBeNonEmptyArray()', () => { expect(['i', 'am not empty']).toEqual(expect.toBeNonEmptyArray()); });
5,901
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-non-empty-object.spec.ts
import 'expect-more-jest'; it('provides expect().toBeNonEmptyObject()', () => { expect({ i: 'am not empty' }).toBeNonEmptyObject(); }); it('provides expect().not.toBeNonEmptyObject()', () => { expect(() => expect({ i: 'am not empty' }).not.toBeNonEmptyObject()).toThrow(); }); it('provides expect.toBeNonEmptyObject()', () => { expect({ i: 'am not empty' }).toEqual(expect.toBeNonEmptyObject()); });
5,902
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-non-empty-string.spec.ts
import 'expect-more-jest'; it('provides expect().toBeNonEmptyString()', () => { expect('i am not empty').toBeNonEmptyString(); }); it('provides expect().not.toBeNonEmptyString()', () => { expect(() => expect('i am not empty').not.toBeNonEmptyString()).toThrow(); }); it('provides expect.toBeNonEmptyString()', () => { expect('i am not empty').toEqual(expect.toBeNonEmptyString()); });
5,903
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-nullable-of.spec.ts
import 'expect-more-jest'; const expectedShape = { x: expect.toBeNumber(), y: expect.toBeNumber(), }; it('provides expect().toBeNullableOf()', () => { expect({ x: 0, y: 12 }).toBeNullableOf(expectedShape); expect(null).toBeNullableOf(expectedShape); }); it('provides expect().not.toBeNullableOf()', () => { expect('mismatch').not.toBeNullableOf(expectedShape); expect(() => expect({ x: 0, y: 12 }).not.toBeNullableOf(expectedShape)).toThrow(); }); it('provides expect.toBeNullableOf()', () => { expect({ x: 0, y: 12 }).toEqual(expect.toBeNullableOf(expectedShape)); });
5,904
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-number.spec.ts
import 'expect-more-jest'; it('provides expect().toBeNumber()', () => { expect(8).toBeNumber(); }); it('provides expect().not.toBeNumber()', () => { expect(() => expect(8).not.toBeNumber()).toThrow(); }); it('provides expect.toBeNumber()', () => { expect(8).toEqual(expect.toBeNumber()); });
5,905
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-object.spec.ts
import 'expect-more-jest'; it('provides expect().toBeObject()', () => { expect({}).toBeObject(); }); it('provides expect().not.toBeObject()', () => { expect(() => expect({}).not.toBeObject()).toThrow(); }); it('provides expect.toBeObject()', () => { expect({}).toEqual(expect.toBeObject()); });
5,906
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-odd-number.spec.ts
import 'expect-more-jest'; it('provides expect().toBeOddNumber()', () => { expect(5).toBeOddNumber(); }); it('provides expect().not.toBeOddNumber()', () => { expect(() => expect(5).not.toBeOddNumber()).toThrow(); }); it('provides expect.toBeOddNumber()', () => { expect(5).toEqual(expect.toBeOddNumber()); });
5,907
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-optional-of.spec.ts
import 'expect-more-jest'; const expectedShape = { x: expect.toBeNumber(), y: expect.toBeNumber(), }; it('provides expect().toBeOptionalOf()', () => { expect({ x: 0, y: 12 }).toBeOptionalOf(expectedShape); expect(undefined).toBeOptionalOf(expectedShape); }); it('provides expect().not.toBeOptionalOf()', () => { expect('mismatch').not.toBeOptionalOf(expectedShape); expect(() => expect({ x: 0, y: 12 }).not.toBeOptionalOf(expectedShape)).toThrow(); }); it('provides expect.toBeOptionalOf()', () => { expect({ x: 0, y: 12 }).toEqual(expect.toBeOptionalOf(expectedShape)); });
5,908
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-positive-number.spec.ts
import 'expect-more-jest'; it('provides expect().toBePositiveNumber()', () => { expect(5).toBePositiveNumber(); }); it('provides expect().not.toBePositiveNumber()', () => { expect(() => expect(5).not.toBePositiveNumber()).toThrow(); }); it('provides expect.toBePositiveNumber()', () => { expect(5).toEqual(expect.toBePositiveNumber()); });
5,909
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-reg-exp.spec.ts
import 'expect-more-jest'; it('provides expect().toBeRegExp()', () => { expect(new RegExp('i am a regular expression')).toBeRegExp(); }); it('provides expect().not.toBeRegExp()', () => { expect(() => expect(new RegExp('i am a regular expression')).not.toBeRegExp()).toThrow(); }); it('provides expect.toBeRegExp()', () => { expect(new RegExp('i am a regular expression')).toEqual(expect.toBeRegExp()); });
5,910
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-same-length-as.spec.ts
import 'expect-more-jest'; it('provides expect().toBeSameLengthAs()', () => { expect(['i also have', '2 items']).toBeSameLengthAs(['i have', '2 items']); }); it('provides expect().not.toBeSameLengthAs()', () => { expect(() => expect(['i also have', '2 items']).not.toBeSameLengthAs(['i have', '2 items']), ).toThrow(); }); it('provides expect.toBeSameLengthAs()', () => { expect(['i also have', '2 items']).toEqual(expect.toBeSameLengthAs(['i have', '2 items'])); });
5,911
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-shorter-than.spec.ts
import 'expect-more-jest'; it('provides expect().toBeShorterThan()', () => { expect(['i have one item']).toBeShorterThan(['i', 'have', 4, 'items']); }); it('provides expect().not.toBeShorterThan()', () => { expect(() => expect(['i have one item']).not.toBeShorterThan(['i', 'have', 4, 'items']), ).toThrow(); }); it('provides expect.toBeShorterThan()', () => { expect(['i have one item']).toEqual(expect.toBeShorterThan(['i', 'have', 4, 'items'])); });
5,912
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-string.spec.ts
import 'expect-more-jest'; it('provides expect().toBeString()', () => { expect('i am a string').toBeString(); }); it('provides expect().not.toBeString()', () => { expect(() => expect('i am a string').not.toBeString()).toThrow(); }); it('provides expect.toBeString()', () => { expect('i am a string').toEqual(expect.toBeString()); });
5,913
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-true.spec.ts
import 'expect-more-jest'; it('provides expect().toBeTrue()', () => { expect(true).toBeTrue(); }); it('provides expect().not.toBeTrue()', () => { expect(() => expect(true).not.toBeTrue()).toThrow(); }); it('provides expect.toBeTrue()', () => { expect(true).toEqual(expect.toBeTrue()); });
5,914
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-valid-date.spec.ts
import 'expect-more-jest'; it('provides expect().toBeValidDate()', () => { expect(new Date('2020-01-01')).toBeValidDate(); }); it('provides expect().not.toBeValidDate()', () => { expect(() => expect(new Date('2020-01-01')).not.toBeValidDate()).toThrow(); }); it('provides expect.toBeValidDate()', () => { expect(new Date('2020-01-01')).toEqual(expect.toBeValidDate()); });
5,915
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-visible-string.spec.ts
import 'expect-more-jest'; it('provides expect().toBeVisibleString()', () => { expect('i am visible').toBeVisibleString(); }); it('provides expect().not.toBeVisibleString()', () => { expect(() => expect('i am visible').not.toBeVisibleString()).toThrow(); }); it('provides expect.toBeVisibleString()', () => { expect('i am visible').toEqual(expect.toBeVisibleString()); });
5,916
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-walkable.spec.ts
import 'expect-more-jest'; it('provides expect().toBeWalkable()', () => { expect({}).toBeWalkable(); }); it('provides expect().not.toBeWalkable()', () => { expect(() => expect({}).not.toBeWalkable()).toThrow(); }); it('provides expect.toBeWalkable()', () => { expect({}).toEqual(expect.toBeWalkable()); });
5,917
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-whitespace.spec.ts
import 'expect-more-jest'; it('provides expect().toBeWhitespace()', () => { expect(' ').toBeWhitespace(); }); it('provides expect().not.toBeWhitespace()', () => { expect(() => expect(' ').not.toBeWhitespace()).toThrow(); }); it('provides expect.toBeWhitespace()', () => { expect(' ').toEqual(expect.toBeWhitespace()); });
5,918
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-whole-number.spec.ts
import 'expect-more-jest'; it('provides expect().toBeWholeNumber()', () => { expect(8).toBeWholeNumber(); }); it('provides expect().not.toBeWholeNumber()', () => { expect(() => expect(8).not.toBeWholeNumber()).toThrow(); }); it('provides expect.toBeWholeNumber()', () => { expect(8).toEqual(expect.toBeWholeNumber()); });
5,919
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-be-within-range.spec.ts
import 'expect-more-jest'; it('provides expect().toBeWithinRange()', () => { expect(7).toBeWithinRange(0, 10); }); it('provides expect().not.toBeWithinRange()', () => { expect(() => expect(7).not.toBeWithinRange(0, 10)).toThrow(); }); it('provides expect.toBeWithinRange()', () => { expect(7).toEqual(expect.toBeWithinRange(0, 10)); });
5,920
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-end-with.spec.ts
import 'expect-more-jest'; it('provides expect().toEndWith()', () => { expect('JavaScript').toEndWith('Script'); }); it('provides expect().not.toEndWith()', () => { expect(() => expect('JavaScript').not.toEndWith('Script')).toThrow(); }); it('provides expect.toEndWith()', () => { expect('JavaScript').toEqual(expect.toEndWith('Script')); });
5,921
0
petrpan-code/JamieMason/expect-more/packages/expect-more-jest
petrpan-code/JamieMason/expect-more/packages/expect-more-jest/test/to-start-with.spec.ts
import 'expect-more-jest'; it('provides expect().toStartWith()', () => { expect('JavaScript').toStartWith('Java'); }); it('provides expect().not.toStartWith()', () => { expect(() => expect('JavaScript').not.toStartWith('Java')).toThrow(); }); it('provides expect.toStartWith()', () => { expect('JavaScript').toEqual(expect.toStartWith('Java')); });
5,930
0
petrpan-code/JamieMason/expect-more/packages/expect-more
petrpan-code/JamieMason/expect-more/packages/expect-more/src/is-array-including-all-of.ts
import { isArray } from './is-array'; import { curry2 } from './lib/curry2'; import { every } from './lib/every'; import { isJestEqual } from './lib/is-jest-equal'; import { some } from './lib/some'; /** * 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`. * @param requiredValues ['Ivo', 14] * @param value [12, 0, 14, 'Ivo'] * @matcherName toBeArrayIncludingAllOf * @memberMatcherName toHaveArrayIncludingAllOf * @matcherMessage expected ${value} to include every value provided in * ${requiredValues} * @matcherNotMessage expected ${value} not to include every value provided in * ${requiredValues} */ export const isArrayIncludingAllOf = curry2( (requiredValues: unknown[], value: unknown): value is any[] => isArray(requiredValues) && isArray(value) && every((requiredValue) => some(isJestEqual(requiredValue), value), requiredValues), );
5,931
0
petrpan-code/JamieMason/expect-more/packages/expect-more
petrpan-code/JamieMason/expect-more/packages/expect-more/src/is-array-including-any-of.ts
import { isArray } from './is-array'; import { curry2 } from './lib/curry2'; import { isJestEqual } from './lib/is-jest-equal'; import { some } from './lib/some'; /** * Asserts that `value` is an `Array` including at least one of the members of * `allowedValues`. * @param allowedValues ['Ginola', 3] * @param value [12, 0, 14, 'Ginola'] * @matcherName toBeArrayIncludingAnyOf * @memberMatcherName toHaveArrayIncludingAnyOf * @matcherMessage expected ${value} to include at least one of the values in * ${allowedValues} * @matcherNotMessage expected ${value} not to include at least one of the * values in ${allowedValues} */ export const isArrayIncludingAnyOf = curry2( (allowedValues: unknown[], value: unknown): value is any[] => isArray(allowedValues) && isArray(value) && some((allowedValue: unknown) => some(isJestEqual(allowedValue), value), allowedValues), );
5,932
0
petrpan-code/JamieMason/expect-more/packages/expect-more
petrpan-code/JamieMason/expect-more/packages/expect-more/src/is-array-including-only.ts
import { isArray } from './is-array'; import { curry2 } from './lib/curry2'; import { every } from './lib/every'; import { isJestEqual } from './lib/is-jest-equal'; import { some } from './lib/some'; /** * 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`. * @param allowedValues [1, 5, 10] * @param value [5, 10, 1] * @matcherName toBeArrayIncludingOnly * @memberMatcherName toHaveArrayIncludingOnly * @matcherMessage expected ${value} to only include values featured in * ${allowedValues} and no others * @matcherNotMessage expected ${value} not to only include values featured in * ${allowedValues} and no others */ export const isArrayIncludingOnly = curry2( (allowedValues: unknown[], value: unknown): value is any[] => isArray(allowedValues) && isArray(value) && every((member: unknown) => some(isJestEqual(member), allowedValues), value), );
6,081
0
petrpan-code/JamieMason/expect-more/packages/expect-more/test
petrpan-code/JamieMason/expect-more/packages/expect-more/test/lib/curry.spec.ts
import { curry1 } from '../../src/lib/curry1'; import { curry2 } from '../../src/lib/curry2'; import { curry3 } from '../../src/lib/curry3'; describe('curry1', () => { it('provides currying for unary type guards', () => { const spy = jest.fn(); const fn: any = curry1(spy as any); fn(); expect(spy).not.toHaveBeenCalled(); fn(1); expect(spy).toHaveBeenCalledWith(1); fn(2, 3); expect(spy).toHaveBeenCalledWith(2); }); }); describe('curry2', () => { it('provides currying for binary type guards', () => { const spy = jest.fn(); const fn: any = curry2(spy as any); fn(); expect(spy).not.toHaveBeenCalled(); fn(1); expect(spy).not.toHaveBeenCalled(); fn(1, 2); expect(spy).toHaveBeenCalledWith(1, 2); fn(3)(4); expect(spy).toHaveBeenCalledWith(3, 4); fn(5, 6, 7); expect(spy).toHaveBeenCalledWith(5, 6); }); }); describe('curry3', () => { it('provides currying for ternary type guards', () => { const spy = jest.fn(); const fn: any = curry3(spy as any); fn(); expect(spy).not.toHaveBeenCalled(); fn(1); expect(spy).not.toHaveBeenCalled(); fn(1, 2); expect(spy).not.toHaveBeenCalled(); fn(1, 2, 3); expect(spy).toHaveBeenCalledWith(1, 2, 3); fn(4)(5)(6); expect(spy).toHaveBeenCalledWith(4, 5, 6); fn(7, 8, 9, 10); expect(spy).toHaveBeenCalledWith(7, 8, 9); }); });
6,082
0
petrpan-code/JamieMason/expect-more
petrpan-code/JamieMason/expect-more/scripts/generate-docs.ts
import fs from 'fs'; import path from 'path'; import ts from 'typescript'; const generateDocsForPackage = (name: string): void => { const rootDir = path.resolve(__dirname, '..'); const fullApi = []; const visitFile = ({ filePath, gitHubUrl }) => { const code = fs.readFileSync(filePath, 'utf8'); const setParentNodes = true; const sourceFile = ts.createSourceFile(filePath, code, ts.ScriptTarget.ES2015, setParentNodes); const api = { matcher: null, asymmetricMatcher: null, }; const visitNode = (node) => { switch (node.kind) { case ts.SyntaxKind.InterfaceDeclaration: const isAsymmetricMatcher = node.name.text === 'Expect'; const isMatcher = node.name.text === 'Matchers'; if (isAsymmetricMatcher || isMatcher) { const methodSignature = node.members[0]; const [jsDoc] = methodSignature.jsDoc || [{ comment: '', tags: [] }]; const shortName = methodSignature.name.text; const name = isAsymmetricMatcher ? `expect.${shortName}` : shortName; const signature = isMatcher ? `expect(value: any).${methodSignature.getText()}` : `expect.${methodSignature.getText()}`; const description = jsDoc.comment; const examples = jsDoc.tags .filter(({ tagName }) => tagName.text === 'example') .map(({ comment }) => comment); api[isAsymmetricMatcher ? 'asymmetricMatcher' : 'matcher'] = { name, signature, description, examples, gitHubUrl, }; } break; } ts.forEachChild(node, visitNode); }; fullApi.push(api); visitNode(sourceFile); }; const packagePath = path.resolve(rootDir, `./packages/${name}/src`); const files = fs .readdirSync(packagePath) .filter((filename) => filename.endsWith('.ts') && !filename.endsWith('index.ts')) .map((filename) => ({ filePath: path.resolve(packagePath, filename), gitHubUrl: `https://github.com/JamieMason/expect-more/blob/master/packages/${name}/src/${filename}`, })); files.forEach(visitFile); console.log('```js'); console.log(`describe('${name}', () => {`); console.log(` it('makes your tests and output easier to read', () => {`); fullApi.forEach(({ matcher }) => { matcher.examples.forEach((example) => { console.log(` ${example}`); }); }); console.log(` });`); console.log(`});`); console.log('```'); }; generateDocsForPackage('expect-more-jest'); generateDocsForPackage('expect-more-jasmine');
6,085
0
petrpan-code/JamieMason/expect-more/scripts
petrpan-code/JamieMason/expect-more/scripts/generate-matchers/index.ts
import { resolve } from 'path'; import ts from 'typescript'; import { generateJasmineIndex } from './jasmine-index'; import { generateJasmineMatcher } from './jasmine-matcher'; import { generateJasmineMemberMatcher } from './jasmine-member-matcher'; import { generateJasmineMatcherTest } from './jasmine-matcher-test'; import { generateJasmineMemberMatcherTest } from './jasmine-member-matcher-test'; import { generateJestIndex } from './jest-index'; import { generateJestMatcher } from './jest-matcher'; import { generateJestMatcherTest } from './jest-matcher-test'; import { allFilePaths, expectMoreJasminePath, expectMoreJestPath, rootFilePaths } from './paths'; export interface FileJsDoc { description: string; matcherMessage: string; matcherName: string; matcherNotMessage: string; memberMatcherName: string; params: Array<{ name: string; exampleValue: string; }>; } export interface FileMeta { filePath: string; inputs: string[]; inputsWithoutTypes: string[]; jasmineMatcherPath: string; jasmineMatcherTestPath: string; jasmineMemberMatcherPath: string; jasmineMemberMatcherTestPath: string; jestMatcherPath: string; jestMatcherTestPath: string; jestMemberMatcherPath: string; jestMemberMatcherTestPath: string; jsDoc: FileJsDoc; matcherInputs: string[]; matcherInputsWithoutTypes: string[]; memberMatcherInputs: string[]; memberMatcherInputsWithoutTypes: string[]; name: string; signature: string; } export const camelToKebab = (camel: string): string => camel.replace(/[A-Z]/g, (a) => `-${a.toLowerCase()}`); const isAllowableJasmineMatcher = ({ jsDoc }) => jsDoc.matcherName.search( /^(toBeGreaterThanOrEqualTo|toBeLessThanOrEqualTo|toBeNear|toBeNull|toBeUndefined|toHaveMember|toThrowAnyError|toThrowErrorOfType|toBeTrue|toBeFalse)$/, ) === -1; const isAllowableJasmineMemberMatcher = ({ jsDoc }) => jsDoc.memberMatcherName.search( /^(toHaveMethodThrowingAnyError|toHaveMethodThrowingErrorOfType|toHaveNestedMember)$/, ) === -1; const isAllowableJestMatcher = ({ jsDoc }) => jsDoc.matcherName.search( /^(toBeGreaterThanOrEqualTo|toBeLessThanOrEqualTo|toBeNear|toBeNull|toBeUndefined|toHaveMember|toThrowAnyError|toThrowErrorOfType)$/, ) === -1; const isExportedVariable = ({ kind, modifiers }) => kind === ts.SyntaxKind.VariableStatement && modifiers && modifiers[0] && modifiers[0].kind === ts.SyntaxKind.ExportKeyword; const options = {}; const program = ts.createProgram(allFilePaths, options); const isCurriedFn = ({ initializer }) => initializer && initializer.expression && initializer.expression.escapedText && initializer.expression.escapedText.startsWith('curry'); const isUnaryfunction = ({ initializer }) => initializer && initializer.kind === ts.SyntaxKind.ArrowFunction; const isHasTypeFunction = ({ initializer }) => initializer && initializer.expression && initializer.expression.text === 'hasType'; const getJasmineMatcherPath = (matcherName) => resolve(expectMoreJasminePath, `./${camelToKebab(matcherName)}.ts`); const getJasmineMatcherTestPath = (matcherName) => resolve(expectMoreJasminePath, `../test/${camelToKebab(matcherName)}.spec.ts`); const getJestMatcherPath = (matcherName) => resolve(expectMoreJestPath, `./${camelToKebab(matcherName)}.ts`); const getJestMatcherTestPath = (matcherName) => resolve(expectMoreJestPath, `../test/${camelToKebab(matcherName)}.spec.ts`); const unwrap = (string) => (string ? string.replace(/\n/g, ' ') : ''); const getMetadata = (filePath): FileMeta => { const sourceFile = program.getSourceFile(filePath); const result: FileMeta = { filePath, inputs: [], inputsWithoutTypes: [], jasmineMatcherPath: '', jasmineMatcherTestPath: '', jasmineMemberMatcherPath: '', jasmineMemberMatcherTestPath: '', jestMatcherPath: '', jestMatcherTestPath: '', jestMemberMatcherPath: '', jestMemberMatcherTestPath: '', jsDoc: { description: '', matcherMessage: '', matcherName: '', matcherNotMessage: '', memberMatcherName: '', params: [], }, matcherInputs: [], matcherInputsWithoutTypes: [], memberMatcherInputs: [], memberMatcherInputsWithoutTypes: [], name: '', signature: '', }; const getSignature = (variableDeclaration) => { if (isCurriedFn(variableDeclaration)) { const fn = variableDeclaration.initializer.arguments[0]; const inTypes = fn.parameters.map((param) => param.getText(sourceFile)); const outType = fn.type.getText(sourceFile); const signature = `(${inTypes.join(', ')}) => ${outType}`; return signature; } else if (isUnaryfunction(variableDeclaration)) { const init = variableDeclaration.initializer; const inTypes = init.parameters.map((param) => param.getText(sourceFile)); const outType = init.type.getText(sourceFile); const signature = `(${inTypes.join(', ')}) => ${outType}`; return signature; } else if (isHasTypeFunction(variableDeclaration)) { const init = variableDeclaration.initializer; const outType = init.typeArguments[0].getText(sourceFile); const signature = `(value: unknown) => value is ${outType}`; return signature; } else { throw new Error(`Unrecognised Signature at ${filePath}`); } }; const getArgumentTypes = (variableDeclaration) => { if (isCurriedFn(variableDeclaration)) { const fn = variableDeclaration.initializer.arguments[0]; const signature = fn.parameters.map((param) => param.getText(sourceFile)); return signature; } else if (isUnaryfunction(variableDeclaration)) { const signature = variableDeclaration.initializer.parameters.map((param) => param.getText(sourceFile), ); return signature; } else if (isHasTypeFunction(variableDeclaration)) { return ['value: unknown']; } else { throw new Error(`Unrecognised Signature at ${filePath}`); } }; const visitNode = (node) => { if (node.jsDoc) { const [jsDocComment] = node.jsDoc; result.jsDoc.description = unwrap(jsDocComment.comment); jsDocComment.tags.forEach(({ comment, name, tagName }) => { if (tagName.text === 'param') { result.jsDoc.params.push({ name: name.text, exampleValue: unwrap(comment) }); } else { result.jsDoc[tagName.text] = unwrap(comment); } }); result.jsDoc.matcherMessage = result.jsDoc.matcherMessage.replace(/`/g, '\\`'); result.jsDoc.matcherNotMessage = result.jsDoc.matcherNotMessage.replace(/`/g, '\\`'); } if (isExportedVariable(node)) { const [variableDeclaration] = node.declarationList.declarations; result.name = variableDeclaration.name.text; result.signature = getSignature(variableDeclaration); result.inputs = getArgumentTypes(variableDeclaration); result.jasmineMatcherPath = getJasmineMatcherPath(result.jsDoc.matcherName); result.jasmineMatcherTestPath = getJasmineMatcherTestPath(result.jsDoc.matcherName); result.jasmineMemberMatcherPath = getJasmineMatcherPath(result.jsDoc.memberMatcherName); result.jasmineMemberMatcherTestPath = getJasmineMatcherTestPath( result.jsDoc.memberMatcherName, ); result.jestMatcherPath = getJestMatcherPath(result.jsDoc.matcherName); result.jestMatcherTestPath = getJestMatcherTestPath(result.jsDoc.matcherName); result.matcherInputs = result.inputs.slice(0, result.inputs.length - 1); result.memberMatcherInputs = ['propPath: string'].concat(result.matcherInputs); result.inputsWithoutTypes = result.inputs.map((withType) => withType.split(':')[0]); result.matcherInputsWithoutTypes = result.matcherInputs.map( (withType) => withType.split(':')[0], ); result.memberMatcherInputsWithoutTypes = result.memberMatcherInputs.map( (withType) => withType.split(':')[0], ); } ts.forEachChild(node, visitNode); }; try { visitNode(sourceFile); } catch (err) { console.error('FAIL:', filePath); throw err; } return result; }; (() => { const allMetadata: FileMeta[] = rootFilePaths.map(getMetadata); const jasmineMatcherMetadata: FileMeta[] = allMetadata.filter(isAllowableJasmineMatcher); const jasmineMemberMatcherMetadata: FileMeta[] = allMetadata.filter( isAllowableJasmineMemberMatcher, ); const jestMatcherMetadata: FileMeta[] = allMetadata.filter(isAllowableJestMatcher); jasmineMatcherMetadata.forEach(generateJasmineMatcher); jasmineMatcherMetadata.forEach(generateJasmineMatcherTest); generateJasmineIndex(jasmineMatcherMetadata, jasmineMemberMatcherMetadata); jasmineMemberMatcherMetadata.forEach(generateJasmineMemberMatcher); jasmineMemberMatcherMetadata.forEach(generateJasmineMemberMatcherTest); jestMatcherMetadata.forEach(generateJestMatcher); jestMatcherMetadata.forEach(generateJestMatcherTest); generateJestIndex(); })();
6,088
0
petrpan-code/JamieMason/expect-more/scripts
petrpan-code/JamieMason/expect-more/scripts/generate-matchers/jasmine-matcher.ts
import * as fs from 'fs'; import { FileMeta } from '.'; const withUtil = (_, varName) => { const methodName = varName === 'value' ? 'printReceived' : 'printExpected'; return '${methodName(varName)}'.replace('methodName', methodName).replace('varName', varName); }; export const generateJasmineMatcher = (file: FileMeta): void => { try { const { jasmineMatcherPath, jsDoc, matcherInputs, matcherInputsWithoutTypes, name } = file; const { description, matcherMessage, matcherName, matcherNotMessage, params } = jsDoc; const utilImports = matcherInputs.length > 0 ? 'printExpected, printReceived' : 'printReceived'; const argsForMatcherInterface = matcherInputs.join(', '); const typedArgsForMatcherFunction = ['value: unknown'].concat(matcherInputs).join(', '); const argsForAssertFunction = matcherInputsWithoutTypes.concat('value').join(', '); const valueExample = params.find(({ name }) => name === 'value').exampleValue; const argsExamples = params .filter(({ name }) => name !== 'value') .map(({ exampleValue }) => exampleValue); const argsExamplesSource = argsExamples.join(', '); const jasmineMatcherMessage = matcherMessage.replace(/\$\{([a-z]+)\}/gi, withUtil); const jasmineMatcherNotMessage = matcherNotMessage.replace(/\$\{([a-z]+)\}/gi, withUtil); const source = ` /// <reference types="jasmine" /> import { ${name} } from 'expect-more'; import { ${utilImports} } from 'jest-matcher-utils'; declare global { namespace jasmine { // eslint-disable-next-line @typescript-eslint/no-unused-vars interface Matchers<T> { /** * ${description} * @example * expect(${valueExample}).${matcherName}(${argsExamplesSource}); */ ${matcherName}(${argsForMatcherInterface}): boolean; } } } export const ${matcherName}Matcher: jasmine.CustomMatcherFactory = () => { return { compare(${typedArgsForMatcherFunction}) { const pass = ${name}(${argsForAssertFunction}); const message = pass ? \`${jasmineMatcherNotMessage}\` : \`${jasmineMatcherMessage}\`; return { message, pass }; }, }; }; beforeAll(() => { jasmine.addMatchers({ ${matcherName}: ${matcherName}Matcher }); }); `; fs.writeFileSync(jasmineMatcherPath, source, 'utf8'); } catch (err) { console.error('FAIL:', file); throw err; } };
6,090
0
petrpan-code/JamieMason/expect-more/scripts
petrpan-code/JamieMason/expect-more/scripts/generate-matchers/jasmine-member-matcher.ts
import * as fs from 'fs'; import { FileMeta } from '.'; const withUtil = (_, varName) => { const methodName = varName === 'value' ? 'printReceived' : 'printExpected'; return '${methodName(varName)}'.replace('methodName', methodName).replace('varName', varName); }; export const generateJasmineMemberMatcher = (file: FileMeta): void => { try { const { jasmineMemberMatcherPath, jsDoc, matcherInputs, matcherInputsWithoutTypes, name } = file; const { description, matcherMessage, memberMatcherName, matcherNotMessage, params } = jsDoc; const argsForMatcherInterface = ['propPath: string'].concat(matcherInputs).join(', '); const typedArgsForMatcherFunction = ['value: unknown', 'propPath: string'] .concat(matcherInputs) .join(', '); const argsForAssertFunction = matcherInputsWithoutTypes .concat(`getIn(propPath.split('.'), value)`) .join(', '); const memberMatcherMessage = matcherMessage.replace( 'expected ${value}', "expected value at '${propPath}'", ); const memberMatcherNotMessage = matcherNotMessage.replace( 'expected ${value}', "expected value at '${propPath}'", ); const valueExample = params.find(({ name }) => name === 'value').exampleValue; const argsExamples = params .filter(({ name }) => name !== 'value') .map(({ exampleValue }) => exampleValue); const argsExamplesSource = ["'child.grandchild'"].concat(argsExamples).join(', '); const jasmineMatcherMessage = memberMatcherMessage.replace(/\$\{([a-z]+)\}/gi, withUtil); const jasmineMatcherNotMessage = memberMatcherNotMessage.replace(/\$\{([a-z]+)\}/gi, withUtil); const source = ` import { ${name} } 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> { /** * ${description} * @example * expect({ child: { grandchild: ${valueExample} } }).${memberMatcherName}(${argsExamplesSource}); */ ${memberMatcherName}(${argsForMatcherInterface}): boolean; } } } export const ${memberMatcherName}Matcher: jasmine.CustomMatcherFactory = () => { return { compare(${typedArgsForMatcherFunction}) { const pass = ${name}(${argsForAssertFunction}); const message = pass ? \`${jasmineMatcherNotMessage}\` : \`${jasmineMatcherMessage}\`; return { message, pass }; }, }; }; beforeAll(() => { jasmine.addMatchers({ ${memberMatcherName}: ${memberMatcherName}Matcher }); }); `; fs.writeFileSync(jasmineMemberMatcherPath, source, 'utf8'); } catch (err) { console.error('FAIL:', file); throw err; } };
6,092
0
petrpan-code/JamieMason/expect-more/scripts
petrpan-code/JamieMason/expect-more/scripts/generate-matchers/jest-matcher-test.ts
import * as fs from 'fs'; import { FileMeta } from '.'; export const generateJestMatcherTest = (file: FileMeta): void => { const { jestMatcherTestPath, jsDoc } = file; const { matcherName, params } = jsDoc; let comment = ''; let valueExample = params.find(({ name }) => name === 'value').exampleValue; if (matcherName === 'toBeAsyncFunction') { comment = '// eval is workaround for typescript converting async to non-async'; valueExample = "eval('(async (_) => _)')"; } else if (matcherName === 'toBeGeneratorFunction') { comment = '// eval is workaround for typescript converting generator fns'; valueExample = "eval('(function*() {yield 2;})')"; } const argsExamples = params .filter(({ name }) => name !== 'value') .map(({ exampleValue }) => exampleValue); const argsExamplesSource = argsExamples.join(', '); const source = ` import 'expect-more-jest'; ${comment} it('provides expect().${matcherName}()', () => { expect(${valueExample}).${matcherName}(${argsExamplesSource}); }); it('provides expect().not.${matcherName}()', () => { expect(() => expect(${valueExample}).not.${matcherName}(${argsExamplesSource})).toThrow(); }); it('provides expect.${matcherName}()', () => { expect(${valueExample}).toEqual(expect.${matcherName}(${argsExamplesSource})); }); `; fs.writeFileSync(jestMatcherTestPath, source, 'utf8'); };
6,093
0
petrpan-code/JamieMason/expect-more/scripts
petrpan-code/JamieMason/expect-more/scripts/generate-matchers/jest-matcher.ts
import * as fs from 'fs'; import { FileMeta } from '.'; const withUtil = (_, varName) => { const methodName = varName === 'value' ? 'printReceived' : 'printExpected'; return '${methodName(varName)}'.replace('methodName', methodName).replace('varName', varName); }; export const generateJestMatcher = (file: FileMeta): void => { try { const { jestMatcherPath, jsDoc, matcherInputs, matcherInputsWithoutTypes, name } = file; const { description, matcherMessage, matcherName, matcherNotMessage, params } = jsDoc; const utilImports = matcherInputs.length > 0 ? 'printExpected, printReceived' : 'printReceived'; const argsForMatcherInterface = matcherInputs.join(', '); const typedArgsForMatcherFunction = ['value: unknown'].concat(matcherInputs).join(', '); const argsForAssertFunction = matcherInputsWithoutTypes.concat('value').join(', '); const valueExample = params.find(({ name }) => name === 'value').exampleValue; const argsExamples = params .filter(({ name }) => name !== 'value') .map(({ exampleValue }) => exampleValue); const argsExamplesSource = argsExamples.join(', '); const jestMatcherMessage = matcherMessage.replace(/\$\{([a-z]+)\}/gi, withUtil); const jestMatcherNotMessage = matcherNotMessage.replace(/\$\{([a-z]+)\}/gi, withUtil); const source = ` /// <reference types="jest" /> import { ${name} } from 'expect-more'; import { ${utilImports} } from 'jest-matcher-utils'; import { createResult } from './lib/create-result'; declare global { namespace jest { interface Matchers<R> { /** * ${description} * @example * expect(${valueExample}).${matcherName}(${argsExamplesSource}); */ ${matcherName}(${argsForMatcherInterface}): R; } interface Expect { /** * ${description} * @example * expect(${valueExample}).toEqual( * expect.${matcherName}(${argsExamplesSource}) * ); */ ${matcherName}<T>(${argsForMatcherInterface}): JestMatchers<T>; } } } export const ${matcherName}Matcher = (${typedArgsForMatcherFunction}): jest.CustomMatcherResult => createResult({ message: () => \`${jestMatcherMessage}\`, notMessage: () => \`${jestMatcherNotMessage}\`, pass: ${name}(${argsForAssertFunction}) }); expect.extend({ ${matcherName}: ${matcherName}Matcher }); `; fs.writeFileSync(jestMatcherPath, source, 'utf8'); } catch (err) { console.error('FAIL:', file); throw err; } };
6,094
0
petrpan-code/JamieMason/expect-more/scripts
petrpan-code/JamieMason/expect-more/scripts/generate-matchers/paths.ts
import { readdirSync } from 'fs'; import { resolve } from 'path'; const getFiles = (dirPath) => readdirSync(dirPath) .filter( (filename) => filename.endsWith('.ts') && !filename.endsWith('index.ts') && !filename.endsWith('typings.ts'), ) .map((filename) => resolve(dirPath, filename)); const rootDir = resolve(__dirname, '../..'); const expectMorePath = resolve(rootDir, './packages/expect-more/src'); const expectMoreLibPath = resolve(expectMorePath, './lib'); const libFilePaths = getFiles(expectMoreLibPath); export const expectMoreJasminePath = resolve(rootDir, './packages/expect-more-jasmine/src'); export const expectMoreJestPath = resolve(rootDir, './packages/expect-more-jest/src'); export const rootFilePaths = getFiles(expectMorePath); export const allFilePaths = [...rootFilePaths, ...libFilePaths];