-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Showing
3 changed files
with
114 additions
and
23 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
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 |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* eslint-disable jest/no-export */ | ||
import faker from 'faker'; | ||
import vest from '../../src'; | ||
|
||
const testDummy = (vestRef = vest) => { | ||
const { test } = vestRef; | ||
const failing = ( | ||
name = faker.random.word(), | ||
statement = faker.random.words() | ||
) => | ||
test(name, statement, () => { | ||
throw new Error(); | ||
}); | ||
|
||
const failingWarning = ( | ||
name = faker.random.word(), | ||
statement = faker.random.words() | ||
) => | ||
test(name, statement, () => { | ||
vest.warn(); | ||
throw new Error(); | ||
}); | ||
|
||
const passing = ( | ||
name = faker.random.word(), | ||
statement = faker.random.words() | ||
) => test(name, statement, Function.prototype); | ||
|
||
const passingWarning = ( | ||
name = faker.random.word(), | ||
statement = faker.random.words() | ||
) => | ||
test(name, statement, () => { | ||
vest.warn(); | ||
}); | ||
|
||
const failingAsync = ( | ||
name = faker.random.word(), | ||
{ statement, time = 0 } = {} | ||
) => | ||
test( | ||
name, | ||
statement, | ||
() => | ||
new Promise((resolve, reject) => { | ||
setTimeout(reject, time); | ||
}) | ||
); | ||
|
||
const failingWarningAsync = ( | ||
name = faker.random.word(), | ||
{ statement, time = 0 } = {} | ||
) => | ||
test(name, statement, () => { | ||
vest.warn(); | ||
return new Promise((resolve, reject) => { | ||
setTimeout(reject, time); | ||
}); | ||
}); | ||
|
||
const passingAsync = ( | ||
name = faker.random.word(), | ||
{ statement, time = 0 } = {} | ||
) => | ||
test( | ||
name, | ||
statement, | ||
() => | ||
new Promise(resolve => { | ||
setTimeout(resolve, time); | ||
}) | ||
); | ||
|
||
const passingWarningAsync = ( | ||
name = faker.random.word(), | ||
{ statement, time = 0 } = {} | ||
) => | ||
test(name, statement, () => { | ||
vest.warn(); | ||
return new Promise(resolve => { | ||
setTimeout(resolve, time); | ||
}); | ||
}); | ||
|
||
return { | ||
failing, | ||
passing, | ||
failingAsync, | ||
passingAsync, | ||
failingWarning, | ||
failingWarningAsync, | ||
passingWarning, | ||
passingWarningAsync, | ||
}; | ||
}; | ||
|
||
export default testDummy; | ||
|
||
export const dummyTest = testDummy(); |