Skip to content

Instantly share code, notes, and snippets.

@stalniy
Created June 25, 2018 18:17
Show Gist options
  • Save stalniy/0cc4aac920777d9fdb9207b992e66485 to your computer and use it in GitHub Desktop.
Save stalniy/0cc4aac920777d9fdb9207b992e66485 to your computer and use it in GitHub Desktop.
How people reuse tests
describe('Invoice', function() {
var invoice, user;
describe('by default', function() {
beforeEach(function() {
user = User.create({ role: 'member' });
invoice = user.invoices.create({ price: 10, currency: 'USD' });
});
it('has status "fraud" if amount does not equal to invoice amount', function() {
invoice.paid(1, 'USD');
expect(invoice.status).to.equal('fraud');
});
it('has status "fraud" if currency does not equal to invoice currency', function() {
invoice.paid(10, 'ZWD');
expect(invoice.status).to.equal('fraud');
});
});
describe('when user is admin', function() {
beforeEach(function() {
user = User.create({ role: 'admin' });
invoice = user.invoices.create({ price: 10, currency: 'USD' });
});
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