Skip to content

Commit

Permalink
Revamped the Zombie example.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmohl committed Feb 18, 2012
1 parent dc85a75 commit 33e9757
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 164 deletions.
17 changes: 0 additions & 17 deletions example/mocha-zombie/lib/jquery.placeholder.js

This file was deleted.

81 changes: 10 additions & 71 deletions example/mocha-zombie/lib/jquery.placeholder.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,16 @@
zombie = require("zombie");
require("expectThat.mocha");
browser = new zombie.Browser();
describe("Given a jquery.placholder with", function() {
var input;
input = "";
describe("no value", function() {
describe("when calling placeholder plugin", function() {
return expectThat("should have an input value of 'Start Typing'", function(done) {
browser.visit("http://127.0.0.1/~dmohl/mocha-zombie/specs.html");
return browser.wait(function() {
input = browser.querySelector(".search");
input.value.should(equal("Start Typing"));
return done();
});
});
});
/* TODO: Identify why this is failing
describe "when focusing input without user value", ->
expectThat "should have an input value of ''", (done) ->
browser.visit "http://127.0.0.1/~dmohl/mocha-zombie/specs.html"
browser.wait ->
browser.evaluate "document.getElementById('search').focus()"
input = browser.querySelector ".search"
input.value.should equal ""
done()
*/
return describe("when leaving input without user value", function() {
return expectThat("should have an input value of 'Start Typing'", function(done) {
browser.visit("http://127.0.0.1/~dmohl/mocha-zombie/specs.html");
return browser.wait(function() {
browser.evaluate("document.getElementById('test').focus()");
input = browser.querySelector(".search");
input.value.should(equal("Start Typing"));
return done();
});
});
});
});
return describe("a user supplied value", function() {
describe("when calling placeholder plugin", function() {
return expectThat("should have an input value of 'bacon'", function(done) {
browser.visit("http://127.0.0.1/~dmohl/mocha-zombie/specs.html");
return browser.wait(function() {
browser.fill(".search", "bacon");
input = browser.querySelector(".search");
input.value.should(equal("bacon"));
return done();
});
});
});
describe("when focusing input with user value", function() {
return expectThat("should have an input value of 'bacon'", function(done) {
browser.visit("http://127.0.0.1/~dmohl/mocha-zombie/specs.html");
return browser.wait(function() {
browser.fill(".search", "bacon");
browser.evaluate("document.getElementById('search').focus()");
input = browser.querySelector(".search");
input.value.should(equal("bacon"));
return done();
});
});
});
return describe("when leaving input without user value", function() {
return expectThat("should have an input value of 'bacon'", function(done) {
browser.visit("http://127.0.0.1/~dmohl/mocha-zombie/specs.html");
return browser.wait(function() {
browser.fill(".search", "bacon");
browser.evaluate("document.getElementById('test').focus()");
input = browser.querySelector(".search");
input.value.should(equal("bacon"));
return done();
});
});
describe("When populating two text boxes", function() {
return expectThat("they should have values of foo and bar", function(done) {
return browser.visit("http://127.0.0.1/~dmohl/mocha-zombie/specs.html", function() {
var input1, input2;
browser.fill(".search", "foo").fill("#test", "bar");
input1 = browser.querySelector(".search");
input2 = browser.querySelector("#test");
input1.value.should(equal("foo"));
input2.value.should(equal("bar"));
return done();
});
});
});
Expand Down
7 changes: 0 additions & 7 deletions example/mocha-zombie/specs.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,4 @@
<input id="search" class="search" />
<input id="test" />
</body>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script src="./lib/jquery.placeholder.js"></script>
<script>
$(document).ready(function () {
$(".search").placeholder("Start Typing");
});
</script>
</html>
72 changes: 11 additions & 61 deletions example/mocha-zombie/specs/jquery.placeholder.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,14 @@ require("expectThat.mocha")

browser = new zombie.Browser()

# Ported from Josh Bush's example at http://digitalbush.com/2011/03/29/testing-jquery-plugins-with-node-js-and-jasmine/
describe "Given a jquery.placholder with", ->
input = ""
describe "no value", ->
describe "when calling placeholder plugin", ->
expectThat "should have an input value of 'Start Typing'", (done) ->
browser.visit "http://127.0.0.1/~dmohl/mocha-zombie/specs.html"
browser.wait ->
input = browser.querySelector ".search"
input.value.should equal "Start Typing"
done()

### TODO: Identify why this is failing
describe "when focusing input without user value", ->
expectThat "should have an input value of ''", (done) ->
browser.visit "http://127.0.0.1/~dmohl/mocha-zombie/specs.html"
browser.wait ->
browser.evaluate "document.getElementById('search').focus()"
input = browser.querySelector ".search"
input.value.should equal ""
done()
###
describe "when leaving input without user value", ->
expectThat "should have an input value of 'Start Typing'", (done) ->
browser.visit "http://127.0.0.1/~dmohl/mocha-zombie/specs.html"
browser.wait ->
browser.evaluate "document.getElementById('test').focus()"
input = browser.querySelector ".search"
input.value.should equal "Start Typing"
done()

describe "a user supplied value", ->

describe "when calling placeholder plugin", ->
expectThat "should have an input value of 'bacon'", (done) ->
browser.visit "http://127.0.0.1/~dmohl/mocha-zombie/specs.html"
browser.wait ->
browser.fill ".search", "bacon"
input = browser.querySelector ".search"
input.value.should equal "bacon"
done()

describe "when focusing input with user value", ->
expectThat "should have an input value of 'bacon'", (done) ->
browser.visit "http://127.0.0.1/~dmohl/mocha-zombie/specs.html"
browser.wait ->
browser.fill ".search", "bacon"
browser.evaluate "document.getElementById('search').focus()"
input = browser.querySelector ".search"
input.value.should equal "bacon"
done()

describe "when leaving input without user value", ->
expectThat "should have an input value of 'bacon'", (done) ->
browser.visit "http://127.0.0.1/~dmohl/mocha-zombie/specs.html"
browser.wait ->
browser.fill ".search", "bacon"
browser.evaluate "document.getElementById('test').focus()"
input = browser.querySelector ".search"
input.value.should equal "bacon"
done()
describe "When populating two text boxes", ->
expectThat "they should have values of foo and bar", (done) ->
browser.visit "http://127.0.0.1/~dmohl/mocha-zombie/specs.html", ->
browser
.fill(".search", "foo")
.fill("#test", "bar")
input1 = browser.querySelector ".search"
input2 = browser.querySelector "#test"
input1.value.should equal "foo"
input2.value.should equal "bar"
done()
8 changes: 0 additions & 8 deletions example/mocha-zombie/src/jquery.placeholder.coffee

This file was deleted.

0 comments on commit 33e9757

Please sign in to comment.