-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
033c3ac
commit d880ff3
Showing
113 changed files
with
2,640 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
**/CHANGELOG.md | ||
**/README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/expect-more-jasmine/src/to-be-array-including-all-of.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { isArrayIncludingAllOf } from 'expect-more'; | ||
import { printExpected, printReceived } from 'jest-matcher-utils'; | ||
|
||
declare global { | ||
namespace jasmine { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
interface Matchers<T> { | ||
/** | ||
* Asserts that `value` is an `Array` including all of the values provided in `requiredValues`. It could also include additional values or be in a different order, but if every value in `requiredValues` features in `value` then this will return `true`. | ||
* @example | ||
* expect([12, 0, 14, 'Ivo']).toBeArrayIncludingAllOf(['Ivo', 14]); | ||
*/ | ||
toBeArrayIncludingAllOf(requiredValues: unknown[]): boolean; | ||
} | ||
} | ||
} | ||
|
||
export const toBeArrayIncludingAllOfMatcher: jasmine.CustomMatcherFactory = () => { | ||
return { | ||
compare(value: unknown, requiredValues: unknown[]) { | ||
const pass = isArrayIncludingAllOf(requiredValues, value); | ||
const message = pass | ||
? `expected ${printReceived(value)} not to include every value provided in ${printExpected( | ||
requiredValues, | ||
)}` | ||
: `expected ${printReceived(value)} to include every value provided in ${printExpected( | ||
requiredValues, | ||
)}`; | ||
return { message, pass }; | ||
}, | ||
}; | ||
}; | ||
|
||
beforeAll(() => { | ||
jasmine.addMatchers({ | ||
toBeArrayIncludingAllOf: toBeArrayIncludingAllOfMatcher, | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
packages/expect-more-jasmine/src/to-be-array-including-any-of.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { isArrayIncludingAnyOf } from 'expect-more'; | ||
import { printExpected, printReceived } from 'jest-matcher-utils'; | ||
|
||
declare global { | ||
namespace jasmine { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
interface Matchers<T> { | ||
/** | ||
* Asserts that `value` is an `Array` including at least one of the members of `values`. | ||
* @example | ||
* expect([12, 0, 14, 'Ginola']).toBeArrayIncludingAnyOf(['Ginola', 3]); | ||
*/ | ||
toBeArrayIncludingAnyOf(values: unknown[]): boolean; | ||
} | ||
} | ||
} | ||
|
||
export const toBeArrayIncludingAnyOfMatcher: jasmine.CustomMatcherFactory = () => { | ||
return { | ||
compare(value: unknown, values: unknown[]) { | ||
const pass = isArrayIncludingAnyOf(values, value); | ||
const message = pass | ||
? `expected ${printReceived( | ||
value, | ||
)} not to include at least one of the values in ${printExpected(values)}` | ||
: `expected ${printReceived( | ||
value, | ||
)} to include at least one of the values in ${printExpected(values)}`; | ||
return { message, pass }; | ||
}, | ||
}; | ||
}; | ||
|
||
beforeAll(() => { | ||
jasmine.addMatchers({ | ||
toBeArrayIncludingAnyOf: toBeArrayIncludingAnyOfMatcher, | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
packages/expect-more-jasmine/src/to-be-array-including-only.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { isArrayIncludingOnly } from 'expect-more'; | ||
import { printExpected, printReceived } from 'jest-matcher-utils'; | ||
|
||
declare global { | ||
namespace jasmine { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
interface Matchers<T> { | ||
/** | ||
* Asserts that a value is an `Array` including only the values provided in the given `allowedValues` array and no others. The order and number of times each value appears in either array does not matter. Returns true unless `value` contains a value which does not feature in `allowedValues`. | ||
* @example | ||
* expect([5, 10, 1]).toBeArrayIncludingOnly([1, 5, 10]); | ||
*/ | ||
toBeArrayIncludingOnly(allowedValues: unknown[]): boolean; | ||
} | ||
} | ||
} | ||
|
||
export const toBeArrayIncludingOnlyMatcher: jasmine.CustomMatcherFactory = () => { | ||
return { | ||
compare(value: unknown, allowedValues: unknown[]) { | ||
const pass = isArrayIncludingOnly(allowedValues, value); | ||
const message = pass | ||
? `expected ${printReceived(value)} not to only include values featured in ${printExpected( | ||
allowedValues, | ||
)} and no others` | ||
: `expected ${printReceived(value)} to only include values featured in ${printExpected( | ||
allowedValues, | ||
)} and no others`; | ||
return { message, pass }; | ||
}, | ||
}; | ||
}; | ||
|
||
beforeAll(() => { | ||
jasmine.addMatchers({ | ||
toBeArrayIncludingOnly: toBeArrayIncludingOnlyMatcher, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { isDateBetween } from 'expect-more'; | ||
import { printExpected, printReceived } from 'jest-matcher-utils'; | ||
|
||
declare global { | ||
namespace jasmine { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
interface Matchers<T> { | ||
/** | ||
* Asserts that a value is an instance of `Date` occurring on or after `floor` and on or before `ceiling`. | ||
* @example | ||
* expect(new Date('2019-12-11')).toBeDateBetween(new Date('2019-12-10'), new Date('2019-12-12')); | ||
*/ | ||
toBeDateBetween(floor: unknown, ceiling: unknown): boolean; | ||
} | ||
} | ||
} | ||
|
||
export const toBeDateBetweenMatcher: jasmine.CustomMatcherFactory = () => { | ||
return { | ||
compare(value: unknown, floor: unknown, ceiling: unknown) { | ||
const pass = isDateBetween(floor, ceiling, value); | ||
const message = pass | ||
? `expected ${printReceived( | ||
value, | ||
)} not to be an instance of Date occurring on or after ${printExpected( | ||
floor, | ||
)} and on or before ${printExpected(ceiling)}` | ||
: `expected ${printReceived( | ||
value, | ||
)} to be an instance of Date occurring on or after ${printExpected( | ||
floor, | ||
)} and on or before ${printExpected(ceiling)}`; | ||
return { message, pass }; | ||
}, | ||
}; | ||
}; | ||
|
||
beforeAll(() => { | ||
jasmine.addMatchers({ | ||
toBeDateBetween: toBeDateBetweenMatcher, | ||
}); | ||
}); |
Oops, something went wrong.