Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created July 25, 2019 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasongorman/02e7e685780fa62b3cc93325dafb6208 to your computer and use it in GitHub Desktop.
Save jasongorman/02e7e685780fa62b3cc93325dafb6208 to your computer and use it in GitHub Desktop.
describe("payment accepted", function() {
it("reduces stock count by 1", function () {
const cd = new CD(price = 9.99, stock = 2);
const payments = new StubPayments(accepted = true);
const creditCard = {
number: "1234234545675768",
expiry: "10/22",
cv: "855"
};
cd.buy(payments, creditCard);
assert.equal(cd.stock, 1);
})
})
describe("payment rejected", function () {
it("doesn't change the stock count", function() {
const cd = new CD(price=9.99, stock=2);
const payments = new StubPayments(accepted=false);
const creditCard = {
number: "1234234545675768",
expiry: "10/22",
cv: "855"
};
cd.buy(payments, creditCard);
assert.equal(cd.stock, 2);
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment