Created
June 25, 2018 18:18
-
-
Save stalniy/5ff797dfa17f71ff02c89d252df45a1b to your computer and use it in GitHub Desktop.
Write tests with lazy variables
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
describe('Invoice', function() { | |
def('user', function() { | |
return User.create({ role: 'member' }); | |
}); | |
def('invoice', function() { | |
return $user.invoices.create({ price: 10, currency: 'USD' }); | |
}); | |
describe('by default', function() { | |
it('has status "fraud" if amount does not equal to invoice amount', function() { | |
$invoice.paid(1, 'USD'); | |
expect($invoice.status).to.equal('fraud'); | |
}); | |
}); | |
describe('when user is admin', function() { | |
def('user', function() { | |
return User.create({ role: 'admin' }); | |
}); | |
it('has status "paid" if amount does not equal to invoice amount', function() { | |
$invoice.paid(1, 'USD'); | |
expect($invoice.status).to.equal('paid'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment