Skip to content

Instantly share code, notes, and snippets.

@laribee
Created February 23, 2012 16:24
Show Gist options
  • Select an option

  • Save laribee/1893524 to your computer and use it in GitHub Desktop.

Select an option

Save laribee/1893524 to your computer and use it in GitHub Desktop.
browser testing w/o a browser w/ coffeescript, jsdom and mocha
harness = require('../test_harness')
expect = harness.expect
HtmlEncoder = harness.load('HtmlEncoder')
describe "Escaping html w/ coffee", ->
it "escapes simple P tag", (inform_mocha_we_are_done) ->
harness.testInBrowser inform_mocha_we_are_done, (window) ->
text = '<p>hello</p>'
encoded = HtmlEncoder.encode(window, text)
expect(encoded).to.equal('&lt;p&gt;hello&lt;&#x2F;p&gt;')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment