Skip to content

Instantly share code, notes, and snippets.

@lfac-pt
Last active May 29, 2019 10:01
Show Gist options
  • Save lfac-pt/65fca3674d1d5efeeb7013c9a5073150 to your computer and use it in GitHub Desktop.
Save lfac-pt/65fca3674d1d5efeeb7013c9a5073150 to your computer and use it in GitHub Desktop.
Example 6 of my JavaScript and React unit tests basics
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"}]);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment