aboutsummaryrefslogtreecommitdiff
path: root/js/tests/ElggAjaxOptionsTest.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tests/ElggAjaxOptionsTest.js')
-rw-r--r--js/tests/ElggAjaxOptionsTest.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/js/tests/ElggAjaxOptionsTest.js b/js/tests/ElggAjaxOptionsTest.js
new file mode 100644
index 000000000..a6b40d439
--- /dev/null
+++ b/js/tests/ElggAjaxOptionsTest.js
@@ -0,0 +1,61 @@
+/**
+ * Tests elgg.ajax.handleOptions() with all of the possible valid inputs
+ */
+ElggAjaxOptionsTest = TestCase("ElggAjaxOptionsTest");
+
+ElggAjaxOptionsTest.prototype.testHandleOptionsAcceptsNoArgs = function() {
+ assertNotUndefined(elgg.ajax.handleOptions());
+};
+
+ElggAjaxOptionsTest.prototype.testHandleOptionsAcceptsUrl = function() {
+ var url = 'url',
+ result = elgg.ajax.handleOptions(url);
+
+ assertEquals(url, result.url);
+};
+
+ElggAjaxOptionsTest.prototype.testHandleOptionsAcceptsDataOnly = function() {
+ var options = {},
+ result = elgg.ajax.handleOptions(options);
+
+ assertEquals(options, result.data);
+};
+
+ElggAjaxOptionsTest.prototype.testHandleOptionsAcceptsOptions = function() {
+ var options = {data:{arg:1}},
+ result = elgg.ajax.handleOptions(options);
+
+ assertEquals(options, result);
+
+ function func() {}
+ options = {success: func};
+ result = elgg.ajax.handleOptions(options);
+
+ assertEquals(options, result);
+};
+
+ElggAjaxOptionsTest.prototype.testHandleOptionsAcceptsUrlThenDataOnly = function() {
+ var url = 'url',
+ options = {arg:1},
+ result = elgg.ajax.handleOptions(url, options);
+
+ assertEquals(url, result.url);
+ assertEquals(options, result.data);
+};
+
+ElggAjaxOptionsTest.prototype.testHandleOptionsAcceptsUrlThenSuccessOnly = function() {
+ var url = 'url',
+ result = elgg.ajax.handleOptions(url, elgg.nullFunction);
+
+ assertEquals(url, result.url);
+ assertEquals(elgg.nullFunction, result.success);
+};
+
+ElggAjaxOptionsTest.prototype.testHandleOptionsAcceptsUrlThenOptions = function() {
+ var url = 'url',
+ options = {data:{arg:1}},
+ result = elgg.ajax.handleOptions(url, options);
+
+ assertEquals(url, result.url);
+ assertEquals(options.data, result.data);
+}; \ No newline at end of file