Index: appengine/monorail/static/js/framework/framework-ajax_test.js |
diff --git a/appengine/monorail/static/js/framework/framework-ajax_test.js b/appengine/monorail/static/js/framework/framework-ajax_test.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6193692ae34129078605496c0f5d0e3913d0f41a |
--- /dev/null |
+++ b/appengine/monorail/static/js/framework/framework-ajax_test.js |
@@ -0,0 +1,37 @@ |
+/* Copyright 2016 The Chromium Authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style |
+ * license that can be found in the LICENSE file or at |
+ * https://developers.google.com/open-source/licenses/bsd |
+ */ |
+ |
+/** |
+ * @fileoverview Tests for framework-ajax.js. |
+ */ |
+ |
+var CS_env; |
+ |
+function setUp() { |
+ CS_env = {'token': 'd34db33f'}; |
+} |
+ |
+function testPostData() { |
+ assertEquals( |
+ 'token=d34db33f', |
+ CS_postData({})); |
+ assertEquals( |
+ 'token=d34db33f', |
+ CS_postData({}, true)); |
+ assertEquals( |
+ '', |
+ CS_postData({}, false)); |
+ assertEquals( |
+ 'a=5&b=foo&token=d34db33f', |
+ CS_postData({a: 5, b: 'foo'})); |
+ |
+ var unescaped = {}; |
+ unescaped['f oo?'] = 'b&ar'; |
+ assertEquals( |
+ 'f%20oo%3F=b%26ar', |
+ CS_postData(unescaped, false)); |
+} |