Created
January 28, 2012 14:52
-
-
Save dmohl/1694601 to your computer and use it in GitHub Desktop.
Placeholder jQuery Plugin Spec in CoffeeScript
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 characters
| # 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.placeholder with", -> | |
| input = undefined | |
| describe "no value", -> | |
| before -> input = $("<input />").appendTo("body").placeholder "foo" | |
| describe "when calling placeholder plugin", -> | |
| expectThat -> input.val().should equal "foo" | |
| describe "when focusing input without user value", -> | |
| before -> input.focus() | |
| expectThat -> input.val().should equal "" | |
| describe "when leaving input without user value", -> | |
| before -> input.focus().blur() | |
| expectThat -> input.val().should equal "foo" | |
| describe "a user supplied value", -> | |
| before -> input = $("<input />").appendTo("body").val("bacon").placeholder "foo" | |
| describe "when calling placeholder plugin", -> | |
| expectThat -> input.val().should equal "bacon" | |
| describe "when focusing input with user value", -> | |
| before -> input.focus() | |
| expectThat -> input.val().should equal "bacon" | |
| describe "when leaving input without user value", -> | |
| before -> input.focus().blur() | |
| expectThat -> input.val().should equal "bacon" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment