Skip to content

Instantly share code, notes, and snippets.

@FagnerMartinsBrack
Last active July 15, 2018 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FagnerMartinsBrack/17b08c36320a189b56e32e1b4704508d to your computer and use it in GitHub Desktop.
Save FagnerMartinsBrack/17b08c36320a189b56e32e1b4704508d to your computer and use it in GitHub Desktop.
(Medium) - Decouple Side-Effects
QUnit.test('Allows to filter the list of posts', (assert) => {
const inMemoryDataSource = {
findPostsTitle: () => Promise.resolve(['How to bake a cake', 'How to drive a car', 'A guide to fly']),
};
const ignoreOutHowTos = (postTitle) => postTitle.indexOf('How to') !== -1;
const listOfPostTitles = ListOfPostTitles();
listOfPostTitles.setDataSource(inMemoryDataSource);
return listOfPostTitles.toHtml(ignoreOutHowTos).then((list) => {
assert.strictEqual(list, '<ul><li>A guide to fly</li></ul>');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment