Last active
December 21, 2016 22:49
-
-
Save FagnerMartinsBrack/76d496d2e71e66dd458a0d9ac4a94c46 to your computer and use it in GitHub Desktop.
(Medium) When Code Duplication In Tests Is Acceptable - Cart Test Example
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
module('Shirts cart'); | |
test('a valid product can be retrieved from the cart after being added', () => { | |
const fakeShirt = Product() | |
.asType('shirt') // Mandatory | |
.withSize('XL') // Mandatory | |
.withColor('black'); // Mandatory | |
const cart = ShirtsCart(); | |
cart.addProduct(fakeShirt); | |
expect(cart).toContain(fakeShirt); | |
}); | |
test('when we try to add an invalid product to the cart then it\'s not added', () => { | |
const fakePants = Product() | |
.asType('pants') // Mandatory | |
.withSize('XL') // Mandatory | |
.withColor('black'); // Mandatory | |
const cart = ShirtsCart(); | |
cart.addProduct(fakePants); | |
expect(cart).not.toContain(fakePants); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment