Skip to content

Instantly share code, notes, and snippets.

@dmohl
Created January 28, 2012 14:52
Show Gist options
  • Select an option

  • Save dmohl/1694601 to your computer and use it in GitHub Desktop.

Select an option

Save dmohl/1694601 to your computer and use it in GitHub Desktop.
Placeholder jQuery Plugin Spec in CoffeeScript
# 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