In Class
we'll do this part together
- Start with an empty directory
- Download Jasmine (the standalone zip)
- Unzip it
- Run SpecRunner.html in your browser
- Look at SpecRunner
- Look at the SpecHelper
- Look at the PlayerSpec
we'll do this part together too!
- Clone this repository, it is a solution for last week's
- I've already done the Jasmine and RequireJS integration
- Look at the SpecRunner, compare it to the one from part 1
- Run through the tests-main.js config, compare it to the app's RequireJS config
I'll do this part
- Create a beforeEach block above the first describe
- Create a var called store and initialize it with an empty object
- spyOn sessionStorage's getItem
- Call a fake function on the spy
- Make the fake function take one parameter (the key to the store) and return the value for that key
- Repeat for sessionStorage's setItem
- Remember that sessionStorate (and localStorage) are objects where the values are all string representations of the data stored in them
this is for you to do
- When you initialize Playlist and sessionStorage is empty, it should start empty
- When you initialize Playlist and sessionStorage is not empty...
- When you add a song, a song is added to the array object
- When you add a song, updatePlaylist is called (use
spyOn
within theit
and.toHaveBeenCalled
) - When you remove a song, the song is removed from the array object
- When you remove a song, updatePlaylist is called
- When you update the playlist, the sessionStorage object matches the playlist's array
start this off together
- Create a
this.config
object that gets it's value passed in from the constructor or gets initialized with an empty object - There are 3 jQuery DOM objects used in this view, find them and set them to class variables -- for example
this.$song = $('#song')
- If these variables are defined in the config, set them as that instead -- something like:
config.song || $('#song');
- Make sure all instances of those jQuery objects are switched out with the new class variables
- In PlaylistViewSpec, when you initialize the PlaylistView, give it an object with those 3 variables defined as their base jQuery elements:
$('<form></form>')
,$('<input/>')
, etc...
on your own
- When you submit a form:
- wipe the text from the text field
- create an
<li>
in the current playlist - create an
<li>
with the text from the input - When you delete a song:
- remove the song from the current playlist