aboutsummaryrefslogtreecommitdiff
path: root/node_modules/cookiejar/tests
diff options
context:
space:
mode:
authorAlee14 <alee14498@gmail.com>2017-03-26 15:18:10 -0400
committerAlee14 <alee14498@gmail.com>2017-03-26 15:18:10 -0400
commit29433e2f7dbd0e4a73d3c78ffe1005b922fb5982 (patch)
treeaa0ad3fe59468cbe452ee597e914839b68c01436 /node_modules/cookiejar/tests
parent878fefb4c4e1f12b804ae5c0def433fa873f4c8b (diff)
downloadAleeBot-29433e2f7dbd0e4a73d3c78ffe1005b922fb5982.tar.gz
AleeBot-29433e2f7dbd0e4a73d3c78ffe1005b922fb5982.tar.bz2
AleeBot-29433e2f7dbd0e4a73d3c78ffe1005b922fb5982.zip
Don't mind me i'm adding the discord.js files
Diffstat (limited to 'node_modules/cookiejar/tests')
-rw-r--r--node_modules/cookiejar/tests/test.js87
1 files changed, 87 insertions, 0 deletions
diff --git a/node_modules/cookiejar/tests/test.js b/node_modules/cookiejar/tests/test.js
new file mode 100644
index 0000000..dfa19fc
--- /dev/null
+++ b/node_modules/cookiejar/tests/test.js
@@ -0,0 +1,87 @@
+#!/usr/bin/env node
+var Cookie=require("../cookiejar"),
+ CookieAccessInfo = Cookie.CookieAccessInfo,
+ CookieJar = Cookie.CookieJar,
+ Cookie = Cookie.Cookie;
+
+var assert = require('assert');
+
+// Test Cookie
+var cookie = new Cookie("a=1;domain=.test.com;path=/");
+assert.equal(cookie.name, "a");
+assert.equal(cookie.value, "1");
+assert.equal(cookie.domain, ".test.com");
+assert.equal(cookie.path, "/");
+assert.equal(cookie.secure, false);
+assert.equal(cookie.expiration_date, Infinity);
+
+assert.deepEqual(cookie, new Cookie("a=1;domain=.test.com;path=/"));
+assert.ok(cookie.collidesWith(new Cookie("a=1;domain=.test.com;path=/")));
+
+var cookie = new Cookie("a=1;path=/", ".test.com");
+assert.equal(cookie.domain, ".test.com");
+
+
+// Test CookieJar
+var test_jar = CookieJar();
+test_jar.setCookies(
+ "a=1;domain=.test.com;path=/"
+ +":b=2;domain=test.com;path=/"
+ +":c=3;domain=test.com;path=/;expires=January 1, 1970");
+var cookies=test_jar.getCookies(CookieAccessInfo("test.com","/"))
+assert.equal(cookies.length, 2, "Expires on setCookies fail\n" + cookies.toString());
+assert.equal(cookies.toValueString(), 'a=1;b=2', "Cannot get value string of multiple cookies");
+
+cookies=test_jar.getCookies(CookieAccessInfo("www.test.com","/"))
+assert.equal(cookies.length, 2, "Wildcard domain fail\n" + cookies.toString());
+
+test_jar.setCookies("b=2;domain=test.com;path=/;expires=January 1, 1970");
+cookies=test_jar.getCookies(CookieAccessInfo("test.com","/"))
+assert.equal(cookies.length, 1, "Delete cookie fail\n" + cookies.toString());
+assert.equal(String(test_jar.getCookies(CookieAccessInfo("test.com","/"))), "a=1; domain=.test.com; path=/");
+
+cookie=Cookie("a=1;domain=test.com;path=/;HttpOnly");
+assert.ok(cookie.noscript, "HttpOnly flag parsing failed\n" + cookie.toString());
+
+var test_jar = CookieJar();
+test_jar.setCookies([
+ "a=1;domain=.test.com;path=/"
+ , "a=1;domain=.test.com;path=/"
+ , "a=2;domain=.test.com;path=/"
+ , "b=3;domain=.test.com;path=/"]);
+var cookies=test_jar.getCookies(CookieAccessInfo("test.com","/"))
+assert.equal(cookies.length, 2);
+assert.equal(cookies[0].value, 2);
+
+// Test Ignore Trailing Semicolons (Github Issue #6)
+var cookie = new Cookie("a=1;domain=.test.com;path=/;;;;");
+assert.equal(cookie.name, "a");
+assert.equal(cookie.value, "1");
+assert.equal(cookie.domain, ".test.com");
+assert.equal(cookie.path, "/");
+assert.deepEqual(cookie, new Cookie("a=1;domain=.test.com;path=/"));
+
+// Test request_path and request_domain
+test_jar.setCookie(new Cookie("sub=4;path=/", "test.com"));
+var cookie = test_jar.getCookie("sub", CookieAccessInfo("sub.test.com", "/"));
+assert.equal(cookie, undefined);
+
+var cookie = test_jar.getCookie("sub", CookieAccessInfo("test.com", "/"));
+assert.equal(cookie.name, "sub");
+assert.equal(cookie.domain, "test.com");
+
+test_jar.setCookie(new Cookie("sub=4;path=/accounts", "test.com", "/accounts"));
+var cookie = test_jar.getCookie("sub", CookieAccessInfo("test.com", "/foo"));
+assert.equal(cookie, undefined);
+
+var cookie = test_jar.getCookie("sub", CookieAccessInfo("test.com", "/accounts"));
+assert.equal(cookie.path, "/accounts");
+
+test_jar.setCookie(new Cookie("sub=5;path=/", "test.com", "/accounts"));
+var cookies = test_jar.getCookies(CookieAccessInfo("test.com"));
+assert.equal(cookies.length, 3);
+
+test_jar.setCookie(new Cookie("sub=5;path=/", "test.com", "/accounts"));
+var cookie = test_jar.getCookie('sub', CookieAccessInfo.All);
+assert(cookie);
+assert.equal(cookie.name, 'sub');