Last active
May 29, 2019 09:55
-
-
Save lfac-pt/41a7ee8d06a737e49ed868e395b6bf80 to your computer and use it in GitHub Desktop.
Example 2 of my JavaScript and React unit tests basics
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("deletePost", () => { | |
test("calls the REST API method to delete the post, but only if the user is logged in", () => { | |
const mockUser = new User({ username: "bob" }); | |
mockUser.ajax = spy(); | |
mockUser.login(); | |
mockUser.deletePost(); | |
expect(mockUser.ajax).to.haveCallCount(1); | |
mockUser.logout(); | |
mockUser.deletePost(); | |
expect(mockUser.ajax).to.haveCallCount(0); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment