Permalink
Browse files

Added three tests for http://bit.ly/KNYAxq

  • Loading branch information...
ralphbean committed May 9, 2012
1 parent 3268c26 commit 0e775ab1ea81d09417e502585f452392e4646a3c
Showing with 18 additions and 3 deletions.
  1. +18 −3 tests/test_js.py
@@ -13,7 +13,7 @@ def setUp(self):
def test_js_function(self):
json = self.encode({"onLoad": js_function("do_something")("param")})
eq_(json, '{"onLoad": do_something(\\"param\\")}')
eq_(json, '{"onLoad": do_something("param")}')
def test_js_function_composition(self):
f = js_function("f")
@@ -49,7 +49,22 @@ def test_encoding_widget_id(self):
args = {'onLoad': f}
json = self.encode(args)
eq_(json, '{"onLoad": function(){jQuery(\\"foo\\").click(onClick)}}')
eq_(json, '{"onLoad": function(){jQuery("foo").click(onClick)}}')
json = self.encode({'args':args})
eq_(json, '{"args": {"onLoad": function(){jQuery(\\"foo\\").click(onClick)}}}')
eq_(json, '{"args": {"onLoad": function(){jQuery("foo").click(onClick)}}}')
def test_quotes_no_escape(self):
f = twc.js_callback("function() { return 'c'; }")
json = self.encode({'onLoad': f})
eq_(json, '{"onLoad": function() { return \'c\'; }}')
def test_quotes_escape(self):
f = twc.js_callback("function() { return \"c\"; }")
json = self.encode({'onLoad': f})
eq_(json, '{"onLoad": function() { return "c"; }}')
def test_quotes_tripled(self):
f = twc.js_callback("""function() { return "c"; }""")
json = self.encode({'onLoad': f})
eq_(json, '{"onLoad": function() { return "c"; }}')

0 comments on commit 0e775ab

Please sign in to comment.