Skip to content

Instantly share code, notes, and snippets.

@lfac-pt
Last active May 29, 2019 09:52
Show Gist options
  • Save lfac-pt/22e22b87b962f4e73709bf54be416b10 to your computer and use it in GitHub Desktop.
Save lfac-pt/22e22b87b962f4e73709bf54be416b10 to your computer and use it in GitHub Desktop.
Example 4 of my JavaScript and React unit tests basics
describe("deletePost", () => {
test("calls the REST API method to delete the post", () => {
// Setup
const mockUser = new User({ username: "bob" });
mockUser.ajax = spy();
mockUser.login();
// Action
mockUser.deletePost();
// Assertion
expect(mockUser.ajax).to.haveCallCount(1);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment