-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(types): move types to each matcher
- Loading branch information
1 parent
4817738
commit 62ebe0a
Showing
82 changed files
with
1,126 additions
and
172 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
import { toBeBefore } from './toBeBefore'; | ||
export const toBeAfter = (otherDate, actual) => toBeBefore(actual, otherDate); | ||
|
||
export type ToBeAfter = ( | ||
otherDate: Date, | ||
expectationFailOutput?: any | ||
) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeAfter: ToBeAfter; | ||
} | ||
} | ||
} | ||
|
||
export const toBeAfter: ToBeAfter = (otherDate, actual) => | ||
toBeBefore(actual, otherDate); |
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,2 +1,13 @@ | ||
import { is } from './lib/is'; | ||
export const toBeArray = is.Array; | ||
|
||
export type ToBeArray = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeArray: ToBeArray; | ||
} | ||
} | ||
} | ||
|
||
export const toBeArray: ToBeArray = is.Array; |
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,5 +1,16 @@ | ||
import { every } from './lib/every'; | ||
import { toBeArray } from './toBeArray'; | ||
import { toBeBoolean } from './toBeBoolean'; | ||
export const toBeArrayOfBooleans = (actual) => | ||
|
||
export type ToBeArrayOfBooleans = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeArrayOfBooleans: ToBeArrayOfBooleans; | ||
} | ||
} | ||
} | ||
|
||
export const toBeArrayOfBooleans: ToBeArrayOfBooleans = (actual) => | ||
toBeArray(actual) && every(actual, toBeBoolean); |
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,5 +1,16 @@ | ||
import { every } from './lib/every'; | ||
import { toBeArray } from './toBeArray'; | ||
import { toBeNumber } from './toBeNumber'; | ||
export const toBeArrayOfNumbers = (actual) => | ||
|
||
export type ToBeArrayOfNumbers = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeArrayOfNumbers: ToBeArrayOfNumbers; | ||
} | ||
} | ||
} | ||
|
||
export const toBeArrayOfNumbers: ToBeArrayOfNumbers = (actual) => | ||
toBeArray(actual) && every(actual, toBeNumber); |
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,5 +1,16 @@ | ||
import { every } from './lib/every'; | ||
import { toBeArray } from './toBeArray'; | ||
import { toBeObject } from './toBeObject'; | ||
export const toBeArrayOfObjects = (actual) => | ||
|
||
export type ToBeArrayOfObjects = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeArrayOfObjects: ToBeArrayOfObjects; | ||
} | ||
} | ||
} | ||
|
||
export const toBeArrayOfObjects: ToBeArrayOfObjects = (actual) => | ||
toBeArray(actual) && every(actual, toBeObject); |
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,3 +1,17 @@ | ||
import { toBeArray } from './toBeArray'; | ||
export const toBeArrayOfSize = (size, actual) => | ||
|
||
export type ToBeArrayOfSize = ( | ||
size: number, | ||
expectationFailOutput?: any | ||
) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeArrayOfSize: ToBeArrayOfSize; | ||
} | ||
} | ||
} | ||
|
||
export const toBeArrayOfSize: ToBeArrayOfSize = (size, actual) => | ||
toBeArray(actual) && actual.length === size; |
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,5 +1,16 @@ | ||
import { every } from './lib/every'; | ||
import { toBeArray } from './toBeArray'; | ||
import { toBeString } from './toBeString'; | ||
export const toBeArrayOfStrings = (actual) => | ||
|
||
export type ToBeArrayOfStrings = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeArrayOfStrings: ToBeArrayOfStrings; | ||
} | ||
} | ||
} | ||
|
||
export const toBeArrayOfStrings: ToBeArrayOfStrings = (actual) => | ||
toBeArray(actual) && every(actual, toBeString); |
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,6 +1,19 @@ | ||
import { toBeDate } from './toBeDate'; | ||
|
||
export const toBeBefore = (otherDate, actual) => | ||
export type ToBeBefore = ( | ||
otherDate: Date, | ||
expectationFailOutput?: any | ||
) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeBefore: ToBeBefore; | ||
} | ||
} | ||
} | ||
|
||
export const toBeBefore: ToBeBefore = (otherDate, actual) => | ||
toBeDate(actual) && | ||
toBeDate(otherDate) && | ||
actual.getTime() < otherDate.getTime(); |
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,2 +1,13 @@ | ||
import { is } from './lib/is'; | ||
export const toBeBoolean = is.Boolean; | ||
|
||
export type ToBeBoolean = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeBoolean: ToBeBoolean; | ||
} | ||
} | ||
} | ||
|
||
export const toBeBoolean: ToBeBoolean = is.Boolean; |
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,3 +1,13 @@ | ||
export type ToBeCalculable = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeCalculable: ToBeCalculable; | ||
} | ||
} | ||
} | ||
|
||
export function toBeCalculable(actual) { | ||
return !isNaN(actual * 2); | ||
} |
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,2 +1,13 @@ | ||
import { is } from './lib/is'; | ||
export const toBeDate = is.Date; | ||
|
||
export type ToBeDate = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeDate: ToBeDate; | ||
} | ||
} | ||
} | ||
|
||
export const toBeDate: ToBeDate = is.Date; |
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,2 +1,14 @@ | ||
import { toBeArrayOfSize } from './toBeArrayOfSize'; | ||
export const toBeEmptyArray = (actual) => toBeArrayOfSize(0, actual); | ||
|
||
export type ToBeEmptyArray = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeEmptyArray: ToBeEmptyArray; | ||
} | ||
} | ||
} | ||
|
||
export const toBeEmptyArray: ToBeEmptyArray = (actual) => | ||
toBeArrayOfSize(0, actual); |
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,4 +1,15 @@ | ||
import { is } from './lib/is'; | ||
import { keys } from './lib/keys'; | ||
export const toBeEmptyObject = (actual) => | ||
|
||
export type ToBeEmptyObject = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeEmptyObject: ToBeEmptyObject; | ||
} | ||
} | ||
} | ||
|
||
export const toBeEmptyObject: ToBeEmptyObject = (actual) => | ||
is.Object(actual) && keys(actual).length === 0; |
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,11 @@ | ||
export const toBeEmptyString = (actual) => actual === ''; | ||
export type ToBeEmptyString = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeEmptyString: ToBeEmptyString; | ||
} | ||
} | ||
} | ||
|
||
export const toBeEmptyString: ToBeEmptyString = (actual) => actual === ''; |
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,3 +1,14 @@ | ||
import { toBeNumber } from './toBeNumber'; | ||
export const toBeEvenNumber = (actual) => | ||
|
||
export type ToBeEvenNumber = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeEvenNumber: ToBeEvenNumber; | ||
} | ||
} | ||
} | ||
|
||
export const toBeEvenNumber: ToBeEvenNumber = (actual) => | ||
toBeNumber(actual) && actual % 2 === 0; |
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,2 +1,14 @@ | ||
import { is } from './lib/is'; | ||
export const toBeFalse = (actual) => actual === false || is.False(actual); | ||
|
||
export type ToBeFalse = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeFalse: ToBeFalse; | ||
} | ||
} | ||
} | ||
|
||
export const toBeFalse: ToBeFalse = (actual) => | ||
actual === false || is.False(actual); |
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,2 +1,13 @@ | ||
import { is } from './lib/is'; | ||
export const toBeFunction = is.Function; | ||
|
||
export type ToBeFunction = (expectationFailOutput?: any) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeFunction: ToBeFunction; | ||
} | ||
} | ||
} | ||
|
||
export const toBeFunction: ToBeFunction = is.Function; |
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,4 +1,19 @@ | ||
import { toBeNumber } from './toBeNumber'; | ||
|
||
export const toBeGreaterThanOrEqualTo = (otherNumber, actual) => | ||
toBeNumber(actual) && actual >= otherNumber; | ||
export type ToBeGreaterThanOrEqualTo = ( | ||
otherNumber: number, | ||
expectationFailOutput?: any | ||
) => boolean; | ||
|
||
declare global { | ||
namespace jasmine { | ||
interface Matchers<T> { | ||
toBeGreaterThanOrEqualTo: ToBeGreaterThanOrEqualTo; | ||
} | ||
} | ||
} | ||
|
||
export const toBeGreaterThanOrEqualTo: ToBeGreaterThanOrEqualTo = ( | ||
otherNumber, | ||
actual | ||
) => toBeNumber(actual) && actual >= otherNumber; |
Oops, something went wrong.