From 441c9e85dcb824dba2a44657a31fa29ad71a4ee1 Mon Sep 17 00:00:00 2001 From: ewinslow Date: Tue, 2 Nov 2010 16:06:53 +0000 Subject: Refs #2538: Moved js directory to elgg root. git-svn-id: http://code.elgg.org/elgg/trunk@7189 36083f99-b078-4883-b0ff-0f9b5a30f544 --- js/tests/ElggSecurityTest.js | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 js/tests/ElggSecurityTest.js (limited to 'js/tests/ElggSecurityTest.js') diff --git a/js/tests/ElggSecurityTest.js b/js/tests/ElggSecurityTest.js new file mode 100644 index 000000000..4324f5671 --- /dev/null +++ b/js/tests/ElggSecurityTest.js @@ -0,0 +1,51 @@ +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); +}; + + -- cgit v1.2.3