Skip to content

Instantly share code, notes, and snippets.

@goldbergyoni
Created December 26, 2018 14:02
Show Gist options
  • Select an option

  • Save goldbergyoni/30c735fca10bf8937491d4b0bae43c47 to your computer and use it in GitHub Desktop.

Select an option

Save goldbergyoni/30c735fca10bf8937491d4b0bae43c47 to your computer and use it in GitHub Desktop.
Mocks focus on the internal
it("When a valid product is about to be deleted, ensure data access DAL was called once, with the right product and right config", async () => {
//Assume we already added a product
const dataAccessMock = sinon.mock(DAL);
//hmmm BAD: testing the internals is actually our main goal here, not just a side-effecr
dataAccessMock.expects("deleteProduct").once().withArgs(DBConfig, theProductWeJustAdded, true, false);
new ProductService().deletePrice(theProductWeJustAdded);
mock.verify();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment