diff options
author | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-02 16:06:53 +0000 |
---|---|---|
committer | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-02 16:06:53 +0000 |
commit | 441c9e85dcb824dba2a44657a31fa29ad71a4ee1 (patch) | |
tree | e3558477d639a95bb5a24807d2a8174c73e1ac83 /engine/js/tests | |
parent | 99b267a9fc4b023e54a9d2c8ec9bd9fe42a32e54 (diff) | |
download | elgg-441c9e85dcb824dba2a44657a31fa29ad71a4ee1.tar.gz elgg-441c9e85dcb824dba2a44657a31fa29ad71a4ee1.tar.bz2 |
Refs #2538: Moved js directory to elgg root.
git-svn-id: http://code.elgg.org/elgg/trunk@7189 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/js/tests')
-rw-r--r-- | engine/js/tests/ElggAjaxOptionsTest.js | 62 | ||||
-rw-r--r-- | engine/js/tests/ElggAjaxTest.js | 59 | ||||
-rw-r--r-- | engine/js/tests/ElggEventsTest.js | 28 | ||||
-rw-r--r-- | engine/js/tests/ElggLanguagesTest.js | 45 | ||||
-rw-r--r-- | engine/js/tests/ElggLibTest.js | 88 | ||||
-rw-r--r-- | engine/js/tests/ElggPriorityListTest.js | 47 | ||||
-rw-r--r-- | engine/js/tests/ElggSecurityTest.js | 51 | ||||
-rw-r--r-- | engine/js/tests/ElggSessionTest.js | 36 |
8 files changed, 0 insertions, 416 deletions
diff --git a/engine/js/tests/ElggAjaxOptionsTest.js b/engine/js/tests/ElggAjaxOptionsTest.js deleted file mode 100644 index 8a2b7f574..000000000 --- a/engine/js/tests/ElggAjaxOptionsTest.js +++ /dev/null @@ -1,62 +0,0 @@ -/**
- * 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',
- success = function() {},
- result = elgg.ajax.handleOptions(url, success);
-
- assertEquals(url, result.url);
- assertEquals(success, 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 diff --git a/engine/js/tests/ElggAjaxTest.js b/engine/js/tests/ElggAjaxTest.js deleted file mode 100644 index 1fa5daca5..000000000 --- a/engine/js/tests/ElggAjaxTest.js +++ /dev/null @@ -1,59 +0,0 @@ -/**
- * Makes sure that each of the helper ajax functions ends up calling $.ajax
- * with the right options.
- */
-ElggAjaxTest = TestCase("ElggAjaxTest");
-
-ElggAjaxTest.prototype.setUp = function() {
-
- this.wwwroot = elgg.config.wwwroot;
- this.ajax = $.ajax;
-
- elgg.config.wwwroot = 'http://www.elgg.org/';
-
- $.ajax = function(options) {
- return options;
- };
-};
-
-ElggAjaxTest.prototype.tearDown = function() {
- $.ajax = this.ajax;
- elgg.config.wwwroot = this.wwwroot;
-};
-
-ElggAjaxTest.prototype.testElggAjax = function() {
- assertEquals(elgg.config.wwwroot, elgg.ajax().url);
-};
-
-ElggAjaxTest.prototype.testElggGet = function() {
- assertEquals('get', elgg.get().type);
-};
-
-ElggAjaxTest.prototype.testElggGetJSON = function() {
- assertEquals('json', elgg.getJSON().dataType);
-};
-
-ElggAjaxTest.prototype.testElggPost = function() {
- assertEquals('post', elgg.post().type);
-};
-
-ElggAjaxTest.prototype.testElggAction = function() {
- assertException(function() { elgg.action(); });
- assertException(function() { elgg.action({}); });
-
- var result = elgg.action('action');
- assertEquals('post', result.type);
- assertEquals('json', result.dataType);
- assertEquals(elgg.config.wwwroot + 'action/action', result.url);
- assertEquals(elgg.security.token.__elgg_ts, result.data.__elgg_ts);
-};
-
-ElggAjaxTest.prototype.testElggAPI = function() {
- assertException(function() { elgg.api(); });
- assertException(function() { elgg.api({}); });
-
- var result = elgg.api('method');
- assertEquals('json', result.dataType);
- assertEquals('method', result.data.method);
- assertEquals(elgg.config.wwwroot + 'services/api/rest/json/', result.url);
-};
diff --git a/engine/js/tests/ElggEventsTest.js b/engine/js/tests/ElggEventsTest.js deleted file mode 100644 index cc30e8418..000000000 --- a/engine/js/tests/ElggEventsTest.js +++ /dev/null @@ -1,28 +0,0 @@ -ElggEventsTest = TestCase("ElggEventsTest"); - -ElggEventsTest.prototype.setUp = function() { - elgg.config.events = {}; - elgg.provide('elgg.config.events.all.all'); -}; - -ElggEventsTest.prototype.testEventHandlersMustBeFunctions = function() { - assertException(function() { elgg.register_event_handler('str', 'str', 'oops'); }); -}; - -ElggEventsTest.prototype.testReturnValueDefaultsToTrue = function() { - assertTrue(elgg.trigger_event('fee', 'fum')); - - elgg.register_event_handler('fee', 'fum', function() {}); - assertTrue(elgg.trigger_event('fee', 'fum')); -}; - -ElggEventsTest.prototype.testCanGlomEventsWithAll = function() { - elgg.register_event_handler('all', 'bar', function() { throw new Error(); }); - assertException("all,bar", function() { elgg.trigger_event('foo', 'bar'); }); - - elgg.register_event_handler('foo', 'all', function() { throw new Error(); }); - assertException("foo,all", function() { elgg.trigger_event('foo', 'baz'); }); - - elgg.register_event_handler('all', 'all', function() { throw new Error(); }); - assertException("all,all", function() { elgg.trigger_event('pinky', 'winky'); }); -};
\ No newline at end of file diff --git a/engine/js/tests/ElggLanguagesTest.js b/engine/js/tests/ElggLanguagesTest.js deleted file mode 100644 index 950d5d3b8..000000000 --- a/engine/js/tests/ElggLanguagesTest.js +++ /dev/null @@ -1,45 +0,0 @@ -ElggLanguagesTest = TestCase("ElggLanguagesTest");
-
-ElggLanguagesTest.prototype.setUp = function() {
- this.ajax = $.ajax;
-
- //Immediately execute some dummy "returned" javascript instead of sending
- //an actual ajax request
- $.ajax = function(settings) {
- var lang = settings.data.js.split('/')[1];
- elgg.config.translations[lang] = {'language':lang};
- };
-};
-
-ElggLanguagesTest.prototype.tearDown = function() {
- $.ajax = this.ajax;
-
- //clear translations
- elgg.config.translations['en'] = undefined;
- elgg.config.translations['aa'] = undefined;
-};
-
-ElggLanguagesTest.prototype.testLoadTranslations = function() {
- assertUndefined(elgg.config.translations['en']);
- assertUndefined(elgg.config.translations['aa']);
-
- elgg.reload_all_translations();
- elgg.reload_all_translations('aa');
-
- assertNotUndefined(elgg.config.translations['en']['language']);
- assertNotUndefined(elgg.config.translations['aa']['language']);
-};
-
-ElggLanguagesTest.prototype.testElggEchoTranslates = function() {
- elgg.reload_all_translations('en');
- elgg.reload_all_translations('aa');
-
- assertEquals('en', elgg.echo('language'));
- assertEquals('aa', elgg.echo('language', 'aa'));
-};
-
-ElggLanguagesTest.prototype.testElggEchoFallsBackToDefaultLanguage = function() {
- elgg.reload_all_translations('en');
- assertEquals('en', elgg.echo('language', 'aa'));
-};
-
diff --git a/engine/js/tests/ElggLibTest.js b/engine/js/tests/ElggLibTest.js deleted file mode 100644 index 035b60325..000000000 --- a/engine/js/tests/ElggLibTest.js +++ /dev/null @@ -1,88 +0,0 @@ -/**
- * Test basic elgg library functions
- */
-ElggLibTest = TestCase("ElggLibTest");
-
-ElggLibTest.prototype.testGlobal = function() {
- assertTrue(window === elgg.global);
-};
-
-ElggLibTest.prototype.testAssertTypeOf = function() {
- var noexceptions = [
- ['string', ''],
- ['object', {}],
- ['boolean', true],
- ['boolean', false],
- ['undefined', undefined],
- ['number', 0],
- ['function', function() {}],
- ];
-
- for (var i in noexceptions) {
- assertNoException(function() {
- elgg.assertTypeOf.apply(elgg, noexceptions[i]);
- });
- }
-
- var exceptions = [
- ['function', {}],
- ['object', function() {}],
- ];
-
- for (var i in exceptions) {
- assertException(function() {
- elgg.assertTypeOf.apply(elgg, exceptions[i]);
- });
- }
-};
-
-ElggLibTest.prototype.testProvide = function() {
- elgg.provide('foo.bar.baz');
-
- assertNotUndefined(foo);
- assertNotUndefined(foo.bar);
- assertNotUndefined(foo.bar.baz);
-
- var str = foo.bar.baz.oof = "don't overwrite me";
-
- elgg.provide('foo.bar.baz');
-
- assertEquals(str, foo.bar.baz.oof);
-};
-
-ElggLibTest.prototype.testRequire = function() {
- /* Try requiring bogus input */
- assertException(function(){ elgg.require(''); });
- assertException(function(){ elgg.require('garbage'); });
- assertException(function(){ elgg.require('gar.ba.ge'); });
-
- assertNoException(function(){ elgg.require('jQuery'); });
- assertNoException(function(){ elgg.require('elgg'); });
- assertNoException(function(){ elgg.require('elgg.config'); });
- assertNoException(function(){ elgg.require('elgg.security'); });
-};
-
-ElggLibTest.prototype.testInherit = function() {
- function Base() {}
- function Child() {}
-
- elgg.inherit(Child, Base);
-
- assertInstanceOf(Base, new Child());
- assertEquals(Child, Child.prototype.constructor);
-};
-
-ElggLibTest.prototype.testExtendUrl = function() {
- elgg.config.wwwroot = "http://elgg.org/";
-
- var inputs = [
- [elgg.config.wwwroot, ''],
- [elgg.config.wwwroot + 'pg/test', 'pg/test'],
- ['http://google.com', 'http://google.com'],
- ['//example.com', '//example.com'],
- ];
-
- for (var i in inputs) {
- assertEquals(inputs[i][0], elgg.normalize_url(inputs[i][1]));
- }
-};
\ No newline at end of file diff --git a/engine/js/tests/ElggPriorityListTest.js b/engine/js/tests/ElggPriorityListTest.js deleted file mode 100644 index 2549e0ee0..000000000 --- a/engine/js/tests/ElggPriorityListTest.js +++ /dev/null @@ -1,47 +0,0 @@ -ElggPriorityListTest = TestCase("ElggPriorityListTest"); - -ElggPriorityListTest.prototype.setUp = function() { - this.list = new elgg.ElggPriorityList(); -}; - -ElggPriorityListTest.prototype.tearDown = function() { - this.list = null; -}; - -ElggPriorityListTest.prototype.testInsert = function() { - this.list.insert('foo'); - - assertEquals('foo', this.list.priorities_[500][0]); - - this.list.insert('bar', 501); - - assertEquals('foo', this.list.priorities_[501][0]); -}; - -ElggPriorityListTest.prototype.testInsertRespectsPriority = function() { - var values = [5, 4, 3, 2, 1, 0]; - - for (var i in values) { - this.list.insert(values[i], values[i]); - } - - this.list.forEach(function(elem, idx)) { - assertEquals(elem, idx); - } -}; - -ElggPriorityListTest.prototype.testInsertHandlesDuplicatePriorities = function() { - values = [0, 1, 2, 3, 4, 5, 6, 7, 8 , 9]; - - for (var i in values) { - this.list.insert(values[i], values[i]/3); - } - - this.list.forEach(function(elem, idx) { - assertEquals(elem, idx); - }); -}; - -ElggPriorityListTest.prototype.testEveryDefaultsToTrue = function() { - assertTrue(this.list.every(function() {})); -};
\ No newline at end of file diff --git a/engine/js/tests/ElggSecurityTest.js b/engine/js/tests/ElggSecurityTest.js deleted file mode 100644 index 4324f5671..000000000 --- a/engine/js/tests/ElggSecurityTest.js +++ /dev/null @@ -1,51 +0,0 @@ -ElggSecurityTest = TestCase("ElggSecurityTest");
-
-ElggSecurityTest.prototype.setUp = function() {
- //fill with fake, but reasonable, values for testing
- this.ts = elgg.security.token.__elgg_ts = 12345;
- this.token = elgg.security.token.__elgg_token = 'abcdef';
-};
-
-ElggSecurityTest.prototype.testAddTokenAcceptsUndefined = function() {
- var input,
- expected = {
- __elgg_ts: this.ts,
- __elgg_token: this.token
- };
-
- assertEquals(expected, elgg.security.addToken(input));
-};
-
-ElggSecurityTest.prototype.testAddTokenAcceptsObject = function() {
- var input = {},
- expected = {
- __elgg_ts: this.ts,
- __elgg_token: this.token
- };
-
- assertEquals(expected, elgg.security.addToken(input));
-};
-
-ElggSecurityTest.prototype.testAddTokenAcceptsString = function() {
- var input,
- str = "__elgg_ts=" + this.ts + "&__elgg_token=" + this.token;
-
- input = "";
- assertEquals(str, elgg.security.addToken(input));
-
- input = "data=sofar";
- assertEquals(input+'&'+str, elgg.security.addToken(input));
-
-};
-
-ElggSecurityTest.prototype.testSetTokenSetsElggSecurityToken = function() {
- var json = {
- __elgg_ts: 4567,
- __elgg_token: 'abcdef'
- };
-
- elgg.security.setToken(json);
- assertEquals(json, elgg.security.token);
-};
-
-
diff --git a/engine/js/tests/ElggSessionTest.js b/engine/js/tests/ElggSessionTest.js deleted file mode 100644 index 0245e9e90..000000000 --- a/engine/js/tests/ElggSessionTest.js +++ /dev/null @@ -1,36 +0,0 @@ -ElggSessionTest = TestCase("ElggSessionTest");
-
-ElggSessionTest.prototype.testGetCookie = function() {
- assertEquals(document.cookie, elgg.session.cookie());
-};
-
-ElggSessionTest.prototype.testGetCookieKey = function() {
- document.cookie = "name=value";
- assertEquals('value', elgg.session.cookie('name'));
-
- document.cookie = "name=value2";
- assertEquals('value2', elgg.session.cookie('name'));
-
- document.cookie = "name=value";
- document.cookie = "name2=value2";
- assertEquals('value', elgg.session.cookie('name'));
- assertEquals('value2', elgg.session.cookie('name2'));
-};
-
-ElggSessionTest.prototype.testSetCookieKey = function() {
- elgg.session.cookie('name', 'value');
- assertEquals('value', elgg.session.cookie('name'));
-
- elgg.session.cookie('name', 'value2');
- assertEquals('value2', elgg.session.cookie('name'));
-
- elgg.session.cookie('name', 'value');
- elgg.session.cookie('name2', 'value2');
- assertEquals('value', elgg.session.cookie('name'));
- assertEquals('value2', elgg.session.cookie('name2'));
-
- elgg.session.cookie('name', null);
- elgg.session.cookie('name2', null);
- assertUndefined(elgg.session.cookie('name'));
- assertUndefined(elgg.session.cookie('name2'));
-};
\ No newline at end of file |