Created
December 17, 2012 02:27
-
-
Save todoubled/4315415 to your computer and use it in GitHub Desktop.
Example casper.js test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query = 'portland' | |
types = 'foo,bar,baz' | |
params = /// chicago/all/#{types} /// | |
casper.start 'http://localhost:8081', -> | |
@setupCookie 'chicago' | |
@reload() | |
.then -> | |
@test.comment 'Select location' | |
@click '#location-trigger' | |
.waitForText 'Enter an address, city or zip code.', -> | |
@test.assertExists 'input#geocode', 'The geocode input is rendered' | |
@fill 'form#set-location', 'geocode': query | |
@click '.location-bar button' | |
.then -> | |
@assertCookie query | |
.waitForText 'Results:', -> | |
@test.assertUrlMatch params, "The search is saved at #finder#{params}." | |
.then -> | |
@test.assertTextExists 'Search results below', 'Search results are shown.' | |
.waitForSelector '#results', -> | |
@assertApiCall query, types | |
.run -> | |
@test.done() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment