Skip to content

Instantly share code, notes, and snippets.

@wesleygrimes
Last active September 24, 2019 17:16
Show Gist options
  • Save wesleygrimes/b5c5e7d308105b7ba5040adf523766c8 to your computer and use it in GitHub Desktop.
Save wesleygrimes/b5c5e7d308105b7ba5040adf523766c8 to your computer and use it in GitHub Desktop.
Simple iteration of test cases in Jasmine or Jest
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