Last active
September 24, 2019 17:16
-
-
Save wesleygrimes/b5c5e7d308105b7ba5040adf523766c8 to your computer and use it in GitHub Desktop.
Simple iteration of test cases in Jasmine or Jest
This file contains hidden or 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
const someMethod = (input: string) => (input === 'value' ? true : false); | |
describe('someMethod', () => { | |
const testCases: Array<[boolean, string]> = [ | |
[true, 'value'], | |
[false, 'other-value'] | |
]; | |
testCases.forEach(([expected, input]: [boolean, string]) => | |
it(`should return ${expected} given ${input}`, () => { | |
// act | |
const actual = someMethod(input); | |
// assert | |
expect(actual).toEqual(expected); | |
}) | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment