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
| import sz from 'sazerac'; | |
| //.test({function_to_test}) | |
| sz.test(addTwoNumbers) | |
| //.case({arguments}, {expected_return_value}): defines a data-driven test case | |
| .case([1, 1], 2) | |
| .case([2, 56], 58) | |
| .case([3, -5], -2) | |
| .case([-4, -6], -10) | |
| //.describeAll({message}): defines a describe message for all cases in the chain |
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
| function isPrime(num) { | |
| for(var i = 2; i < num; i++) { | |
| if(num % i === 0) return false; | |
| } | |
| return num > 1; | |
| } |
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
| describe('isPrime()', () => { | |
| describe('when given 1', () => { | |
| it('should return false', () => { | |
| expect(isPrime(1)).toBe(false) | |
| }) | |
| }) | |
| describe('when given 2', () => { | |
| it('should return true', () => { |
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
| import { test, given } from 'sazerac' | |
| test(isPrime, () => { | |
| given(1).expect(false) | |
| given(2).expect(true) | |
| given(3).expect(true) | |
| given(4).expect(false) | |
| }) |
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
| import React, { PropTypes } from 'react' | |
| const Product = ({ product }) => { | |
| const { title, price, inventory } = product | |
| let err = false | |
| if (!title || !price || !inventory) { | |
| err = true | |
| } |
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
| import { shallow } from 'enzyme' | |
| import Product from './Product' | |
| const ProductComponent = product => { | |
| const component = shallow( | |
| <Product product={product} /> | |
| ) | |
| return { |
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
| test(ProductComponent, () => { | |
| given({}) | |
| .assert('should render `error` class', (p) => { | |
| expect(p.product.hasClass('error')).toBe(true) | |
| }) | |
| }) |
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
| test(ProductComponent, () => { | |
| given({}) | |
| .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) => { |
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
| 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) |
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
| let myContract | |
| newMyContract(init).then((_myContract) => { | |
| myContract = _myContract | |
| return myContract.contribute() | |
| }).then(() => { | |
| return myContract.changeTime(finalTime) | |
| }).then(() => { | |
| return myContract.recipientWithdraw() | |
| }).then(() => { | |
| return myContract.getBalance() |
OlderNewer