Skip to content

Instantly share code, notes, and snippets.

@chrisfosterelli
Created November 19, 2015 21:25
Show Gist options
  • Save chrisfosterelli/4d2dcd38a24fe9517ee2 to your computer and use it in GitHub Desktop.
Save chrisfosterelli/4d2dcd38a24fe9517ee2 to your computer and use it in GitHub Desktop.
WORKSHOP 1
==========
Welcome!
Step 1: Download a Basic Jasmine Setup
: https://drive.google.com/file/d/0B16WkmKMiD-KWUVnUnFqWHBMVlE/view
Step 2: Unzip the file
Step 3: Open the SpecRunner.html file
: Yay, you should have running tests now!
Step 4: In the SpecRunner.html file, uncomment the prettyTime.js file loads
Step 5: Add the following tests for the prettyTime function:
: it should return 'just now' when appropriate
: it should return 'minutes ago' when appropriate
: it should return 'hour ago' when appropriate
: it should return 'hours ago' when appropriate
: it should return yesterday when appropriate
: it should return 'days ago' when appropriate
: it should return 'weeks ago' when appropriate
: it should return undefined for dates in the future
: it should return undefined for dates over a month ago
: it should return undefined for invalid dates
Step 6: In the SpecRunner.html file, uncomment the reverse.js file loads
Step 7: Add a function that implements the test in the specification for reverse.js
Step 8: Once all your tests are passing, call me over!
Bonus points:
Create a function that makes an AJAX call to a publically available
resource, and provide a test suite that examples the return value.
This code should properly test the asynchronous behaviour of the
Javascript.
To do this, check out the Jasmine specification: http://jasmine.github.io/2.3/introduction.html
Double bonus points:
Modify the original prettyTime function so that it does *not* take
a "now" parameter. It should simply determine the current time based
on the system clock. To properly test this, you'll have to "fake"
the system clock now. The jasmine introduction has details on how
to fake a clock.
Let me know if you finish!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment