aboutsummaryrefslogtreecommitdiff
path: root/engine/js/tests/ElggSessionTest.js
blob: 0245e9e909473c487a1e37413525094d02e9816e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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'));
};