Created
November 24, 2011 10:43
-
-
Save clarkdave/1391070 to your computer and use it in GitHub Desktop.
Revisions
-
clarkdave created this gist
Nov 24, 2011 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ var phantom = require('phantom'), vows = require('vows'), assert = require('assert'); // nesting tests inside phantom callback so we only // have to create it once phantom.create(function(ph) { var get_page_result = function(url, fn, result) { ph.createPage(function(page) { page.open(url, function(status) { if (status != 'success') result(new Error('Could not connect'), null) else { page.evaluate(fn, function(r) { result(null, r) ph.exit() }) } }) }) } vows.describe('Correct UI state').addBatch({ 'pending requests': { topic: function() { get_page_result('http://localhost:8081/something', function() { return document.querySelectorAll('#something .item') }, this.callback) }, 'is there': function(err, result) { assert.isNull(err) assert.isNotNull(result) } } }).run({}, function() { // kill the phantom object after tests run ph.exit() }) })