I hereby claim:
- I am lfac-pt on github.
- I am lfac (https://keybase.io/lfac) on keybase.
- I have a public key ASDCheImHpqMXskAg5Co-JlCLsxnTElp7P7bm-HuOboO7wo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
describe("deleteUser", () => { | |
test("makes a request to the delete user endpoint", () => { | |
// Test code | |
}); | |
}); | |
describe("render", () => { | |
test("renders the user name if the user is logged in", () => { | |
// Test code | |
}); |
class Dialog extends Component { | |
deleteUser() { | |
// `deleteUser` implementation | |
} | |
render() { | |
// `render` implementation | |
} | |
} |
<METHOD_NAME> | |
<TEST> | |
<TEST> | |
... | |
<METHOD_NAME> | |
<TEST> | |
<TEST> | |
... |
describe("searchPosts", () => { | |
test("filters the results according to the input search", () => { | |
const mockUser = new User({ username: "bob" }); | |
mockUser.loadPosts = () => [{id: 1, title: "bob"}, {id: 2, title: "alice"}]; | |
expect(mockUser.searchPosts("bob")).toEqual([{id: 1, title: "bob"}]); | |
}); | |
}); |
describe("searchPosts", () => { | |
test("filters the results according to the input search", () => { | |
const loadPostsBackup = User.prototype.loadPosts; | |
User.prototype.loadPosts = () => [{id: 1, title: "bob"}, {id: 2, title: "alice"}]; | |
const mockUser = new User({ username: "bob" }); | |
expect(mockUser.searchPosts("bob")).toEqual([{id: 1, title: "bob"}]); |
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(); |
describe("deletePost", () => { | |
let mockUser; | |
beforeEach(() => { | |
mockUser = new User({ username: "bob" }); | |
mockUser.ajax = spy(); | |
}); | |
test("calls the REST API method to delete the post", () => { |
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); |
test("should update the dom", () => { | |
$("div").text("bob"); | |
expect($("div").text()).toBe("bob"); | |
}); |