Created
February 10, 2017 10:57
-
-
Save kamilogorek/ba356105a499597c5f9a4e015886947b to your computer and use it in GitHub Desktop.
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
test(isPrime, () => { | |
given(1).expect(false) | |
given(2).expect(true) | |
given(3).expect(true) | |
given(4).expect(false) | |
}) | |
// vs. | |
describe('isPrime()', () => { | |
it('handles integers correctly', () => { | |
expect(isPrime(1)).toBe(false) | |
expect(isPrime(2)).toBe(true) | |
expect(isPrime(3)).toBe(true) | |
expect(isPrime(4)).toBe(false) | |
}) | |
}) | |
//////////////// | |
test(ProductComponent, () => { | |
forCases( | |
given({}), | |
given({ price: '1.11', inventory: '111' }), | |
given({ title: 'p1', inventory: '111' }), | |
given({ title: 'p1', price: '1.11' }) | |
) | |
.assert('should render `error` class', (p) => { | |
expect(p.product.hasClass('error')).toBe(true) | |
}) | |
.assert('should display error message', (p) => { | |
expect(p.errorMessage.text()).toMatch(/Please enter all product info/) | |
}) | |
.assert('should not display success message', (p) => { | |
expect(p.successMessage.exists()).toBe(false) | |
}) | |
}) | |
// vs. | |
describe('ProductComponent', () => { | |
const cases = [ | |
{}, | |
{ price: '1.11', inventory: '111' }, | |
{ title: 'p1', inventory: '111' }, | |
{ title: 'p1', price: '1.11' } | |
] | |
cases.forEach((input) => { | |
const p = ProductComponent(input) | |
it('should render `error` class', (p) => expect(p.product.hasClass('error')).toBe(true)) | |
it('should display error message', (p) => expect(p.errorMessage.text()).toMatch(/Please enter all product info/)) | |
it('should not display success message', (p) => expect(p.successMessage.exists()).toBe(false)) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment