Skip to content

Commit

Permalink
feat(playlist): clear playlist #8
Browse files Browse the repository at this point in the history
  • Loading branch information
rudywaltz committed Mar 3, 2019
1 parent 995e83c commit 83c493f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
15 changes: 15 additions & 0 deletions cypress/integration/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,19 @@ describe('player', () => {
})
})

it('clear playlist', () => {
cy.get('.playlist__clear')
.click();

cy
.get('.playlist')
.contains('Choose one song');

cy.window()
.its('store')
.then(store => {
const { playlist } = store.get();
expect(playlist).to.be.empty;
})
})
});
2 changes: 1 addition & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ Cypress.Commands.add("setStorage", (key, value) => {
cy.window()
.its('store')
.then(store => {
store.set({ [key]: value })
store.set({ [key]: value })
})
})
7 changes: 7 additions & 0 deletions src/components/Playlist.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<h2>Playlist</h2>
<button type="button" class="playlist__clear" on:click="clearStore()">Clear</button>
<ul class="playlist">
{#each $playlist as song}
<li class="song">
Expand All @@ -16,6 +17,12 @@ <h3 class="song__title">{ song.title }</h3>
export default {
helpers: {
format
},

methods: {
clearStore: function() {
this.store.set({ playlist: [] });
}
}
}
</script>

0 comments on commit 83c493f

Please sign in to comment.