Permalink
Browse files

Added an example with Zombie.js.

  • Loading branch information...
dmohl committed Jan 22, 2012
1 parent f439c37 commit 615c7eb3bccaf543aecb49ed32958a5a9ecd0b05
Showing 658 changed files with 267,140 additions and 3 deletions.
@@ -0,0 +1,20 @@
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Mocha Tests</title>
+ <link rel="stylesheet" href="https://raw.github.com/visionmedia/mocha/master/mocha.css" />
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
+ <script src="https://raw.github.com/visionmedia/mocha/master/mocha.js"></script>
+ <script type="text/javascript" src="../../lib/expectThat.mocha.js"></script>
+ <script>mocha.setup('bdd')</script>
+ <script src="./min/example.spec.js"></script>
+ <script>
+ $(function () {
+ mocha.run()
+ })
+ </script>
+</head>
+<body>
+ <div id="mocha"></div>
+</body>
+</html>
@@ -0,0 +1,17 @@
+(function() {
+ var $;
+ $ = jQuery;
+ $.fn.placeholder = function(description) {
+ return this.each(function() {
+ var input;
+ input = $(this);
+ return input.on("blur.placeholder", function() {
+ return input.val(input.val() || description);
+ }).on("focus.placeholder", function() {
+ if (input.val() === description) {
+ return input.val('');
+ }
+ }).trigger("blur.placeholder");
+ });
+ };
+}).call(this);
@@ -0,0 +1,78 @@
+(function() {
+ var browser, zombie;
+ 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() {
+ return browser.visit("http://127.0.0.1/~dmohl/mocha-zombie/Index.html", {
+ debug: false
+ }, function(e, brwser, status) {
+ input = brwser.querySelector(".search");
+ return input.value.should(equal("Start Typing"));
+ });
+ });
+ });
+ describe("when focusing input without user value", function() {
+ return expectThat("should have an input value of ''", function() {
+ return browser.visit("http://127.0.0.1/~dmohl/mocha-zombie/Index.html", {
+ debug: false
+ }, function(e, brwser, status) {
+ brwser.evaluate("document.getElementById('search').focus()");
+ input = brwser.querySelector(".search");
+ return brwser.querySelector(".search").value.should(equal(""));
+ });
+ });
+ });
+ return describe("when leaving input without user value", function() {
+ return expectThat("should have an input value of 'Start Typing'", function() {
+ return browser.visit("http://127.0.0.1/~dmohl/mocha-zombie/Index.html", {
+ debug: false
+ }, function(e, brwser, status) {
+ brwser.evaluate("document.getElementById('search').focus().blur()");
+ input = brwser.querySelector(".search");
+ return input.value.should(equal("Start Type"));
+ });
+ });
+ });
+ });
+ return describe("a user supplied value", function() {
+ describe("when calling placeholder plugin", function() {
+ return expectThat("should have an input value of 'bacon'", function() {
+ return browser.visit("http://127.0.0.1/~dmohl/mocha-zombie/Index.html", {
+ debug: false
+ }, function(e, brwser, status) {
+ input = brwser.querySelector(".search");
+ return input.value.should(equal("bacon"));
+ });
+ });
+ });
+ describe("when focusing input with user value", function() {
+ return expectThat("should have an input value of 'bacon'", function() {
+ return browser.visit("http://127.0.0.1/~dmohl/mocha-zombie/Index.html", {
+ debug: false
+ }, function(e, brwser, status) {
+ brwser.evaluate("document.getElementById('search').focus()");
+ input = brwser.querySelector(".search");
+ return input.value.should(equal("bacon"));
+ });
+ });
+ });
+ return describe("when leaving input without user value", function() {
+ return expectThat("should have an input value of 'bacon'", function() {
+ return browser.visit("http://127.0.0.1/~dmohl/mocha-zombie/Index.html", {
+ debug: false
+ }, function(e, brwser, status) {
+ brwser.evaluate("document.getElementById('search').focus().blur()");
+ input = brwser.querySelector(".search");
+ return input.value.should(equal("bacon"));
+ });
+ });
+ });
+ });
+ });
+}).call(this);

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 615c7eb

Please sign in to comment.