mirror of https://github.com/vitalif/phantomjs
parent
a5f0ff7433
commit
b68d9467a7
|
@ -1,100 +0,0 @@
|
|||
describe("CookieJar object", function() {
|
||||
var jar = require('cookiejar').create();
|
||||
|
||||
it("should be creatable", function() {
|
||||
expect(typeof jar).toEqual('object');
|
||||
expect(jar).toNotEqual(null);
|
||||
});
|
||||
|
||||
expectHasProperty(jar, 'cookies');
|
||||
|
||||
expectHasFunction(jar, 'addCookie');
|
||||
expectHasFunction(jar, 'deleteCookie');
|
||||
expectHasFunction(jar, 'clearCookies');
|
||||
|
||||
it("should add a cookie and then remove it", function() {
|
||||
var cookie = {
|
||||
'name' : 'Valid-Cookie-Name',
|
||||
'value' : 'Valid-Cookie-Value',
|
||||
'domain' : 'localhost',
|
||||
'path' : '/foo',
|
||||
'httponly' : true,
|
||||
'secure' : false
|
||||
};
|
||||
|
||||
jar.addCookie(cookie);
|
||||
var cookies = jar.cookies;
|
||||
|
||||
expect(cookies.length).toEqual(1);
|
||||
|
||||
expect(jar.deleteCookie('Valid-Cookie-Name')).toBe(true);
|
||||
|
||||
expect(jar.cookies.length).toBe(0);
|
||||
});
|
||||
|
||||
it("should set and get cookies with .cookies", function() {
|
||||
var cookies = [{
|
||||
'name' : 'Valid-Cookie-Name',
|
||||
'value' : 'Valid-Cookie-Value',
|
||||
'domain' : 'localhost',
|
||||
'path' : '/foo',
|
||||
'httponly' : true,
|
||||
'secure' : false
|
||||
},{
|
||||
'name' : 'Valid-Cookie-Name-Sec',
|
||||
'value' : 'Valid-Cookie-Value-Sec',
|
||||
'domain' : 'localhost',
|
||||
'path' : '/foo',
|
||||
'httponly' : true,
|
||||
'secure' : false,
|
||||
'expires' : new Date().getTime() + 3600 //< expires in 1h
|
||||
}];
|
||||
|
||||
jar.cookies = cookies;
|
||||
expect(jar.cookies.length).toBe(2);
|
||||
|
||||
jar.clearCookies();
|
||||
expect(jar.cookies.length).toEqual(0);
|
||||
|
||||
});
|
||||
|
||||
it("should be separate cookie jars", function() {
|
||||
var jar1 = require('cookiejar').create();
|
||||
var jar2 = require('cookiejar').create();
|
||||
|
||||
var cookie1 = {
|
||||
'name' : 'Valid-Cookie-Name-1',
|
||||
'value' : 'Valid-Cookie-Value',
|
||||
'domain' : 'localhost',
|
||||
'path' : '/foo',
|
||||
'httponly' : true,
|
||||
'secure' : false
|
||||
};
|
||||
|
||||
var cookie2 = {
|
||||
'name' : 'Valid-Cookie-Name-2',
|
||||
'value' : 'Valid-Cookie-Value',
|
||||
'domain' : 'localhost',
|
||||
'path' : '/foo',
|
||||
'httponly' : true,
|
||||
'secure' : false
|
||||
};
|
||||
|
||||
jar1.addCookie(cookie1);
|
||||
|
||||
expect(jar1.cookies.length).toBe(1);
|
||||
expect(jar2.cookies.length).toBe(0);
|
||||
|
||||
jar2.addCookie(cookie2);
|
||||
expect(jar1.deleteCookie('Valid-Cookie-Name-1')).toBe(true);
|
||||
|
||||
expect(jar1.cookies.length).toBe(0);
|
||||
expect(jar2.cookies.length).toBe(1);
|
||||
|
||||
jar1.close();
|
||||
jar2.close();
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
var assert = require('../../assert');
|
||||
var cookiejar = require('cookiejar');
|
||||
|
||||
var jar = cookiejar.create();
|
||||
assert.equal(jar.cookies.length, 0);
|
||||
|
||||
var cookie = {
|
||||
'name' : 'Valid-Cookie-Name',
|
||||
'value' : 'Valid-Cookie-Value',
|
||||
'domain' : 'localhost',
|
||||
'path' : '/foo',
|
||||
'httponly' : true,
|
||||
'secure' : false
|
||||
};
|
||||
|
||||
jar.addCookie(cookie);
|
||||
assert.equal(jar.cookies.length, 1);
|
||||
|
||||
jar.deleteCookie('Valid-Cookie-Name');
|
||||
assert.equal(jar.cookies.length, 0);
|
|
@ -0,0 +1,8 @@
|
|||
var assert = require('../../assert');
|
||||
var cookiejar = require('cookiejar');
|
||||
|
||||
var jar = cookiejar.create();
|
||||
|
||||
assert.typeOf(jar.addCookie, 'function');
|
||||
assert.typeOf(jar.deleteCookie, 'function');
|
||||
assert.typeOf(jar.clearCookies, 'function');
|
|
@ -0,0 +1,35 @@
|
|||
var assert = require('../../assert');
|
||||
var cookiejar = require('cookiejar');
|
||||
|
||||
var jar1 = cookiejar.create();
|
||||
var jar2 = cookiejar.create();
|
||||
|
||||
var cookie1 = {
|
||||
'name' : 'Valid-Cookie-Name-1',
|
||||
'value' : 'Valid-Cookie-Value',
|
||||
'domain' : 'localhost',
|
||||
'path' : '/foo',
|
||||
'httponly' : true,
|
||||
'secure' : false
|
||||
};
|
||||
|
||||
var cookie2 = {
|
||||
'name' : 'Valid-Cookie-Name-2',
|
||||
'value' : 'Valid-Cookie-Value',
|
||||
'domain' : 'localhost',
|
||||
'path' : '/foo',
|
||||
'httponly' : true,
|
||||
'secure' : false
|
||||
};
|
||||
|
||||
jar1.addCookie(cookie1);
|
||||
assert.equal(jar1.cookies.length, 1);
|
||||
assert.equal(jar2.cookies.length, 0);
|
||||
|
||||
jar2.addCookie(cookie2);
|
||||
jar1.deleteCookie('Valid-Cookie-Name-1');
|
||||
assert.equal(jar1.cookies.length, 0);
|
||||
assert.equal(jar2.cookies.length, 1);
|
||||
|
||||
jar1.close();
|
||||
jar2.close();
|
|
@ -0,0 +1,8 @@
|
|||
var assert = require('../../assert');
|
||||
var cookiejar = require('cookiejar');
|
||||
|
||||
var jar = cookiejar.create();
|
||||
|
||||
assert.typeOf(jar, 'object');
|
||||
assert.isTrue(jar !== null);
|
||||
assert.typeOf(jar.cookies, 'object');
|
|
@ -0,0 +1,28 @@
|
|||
var assert = require('../../assert');
|
||||
var cookiejar = require('cookiejar');
|
||||
|
||||
var jar = cookiejar.create();
|
||||
assert.equal(jar.cookies.length, 0);
|
||||
|
||||
var cookies = [{
|
||||
'name' : 'Valid-Cookie-Name',
|
||||
'value' : 'Valid-Cookie-Value',
|
||||
'domain' : 'localhost',
|
||||
'path' : '/foo',
|
||||
'httponly' : true,
|
||||
'secure' : false
|
||||
},{
|
||||
'name' : 'Valid-Cookie-Name-Sec',
|
||||
'value' : 'Valid-Cookie-Value-Sec',
|
||||
'domain' : 'localhost',
|
||||
'path' : '/foo',
|
||||
'httponly' : true,
|
||||
'secure' : false,
|
||||
'expires' : new Date().getTime() + 3600 //< expires in 1h
|
||||
}];
|
||||
|
||||
jar.cookies = cookies;
|
||||
assert.equal(jar.cookies.length, 2);
|
||||
|
||||
jar.clearCookies();
|
||||
expect(jar.cookies.length).toEqual(0);
|
|
@ -69,7 +69,6 @@ phantom.injectJs("./fs-spec-02.js"); //< Filesystem Specs 02 (Attributes)
|
|||
phantom.injectJs("./fs-spec-03.js"); //< Filesystem Specs 03 (Paths)
|
||||
phantom.injectJs("./fs-spec-04.js"); //< Filesystem Specs 04 (Tests)
|
||||
phantom.injectJs("./webkit-spec.js");
|
||||
phantom.injectJs("./cookiejar-spec.js");
|
||||
phantom.injectJs("./webpage-spec.js");
|
||||
require("./module_spec.js");
|
||||
require("./require/require_spec.js");
|
||||
|
|
|
@ -25,6 +25,7 @@ TESTS = [
|
|||
'basics/*.js',
|
||||
'module/system/*.js',
|
||||
'module/webpage/*.js',
|
||||
'module/cookiejar/*.js',
|
||||
'standards/javascript/*.js',
|
||||
'standards/console/*.js',
|
||||
'regression/*.js',
|
||||
|
|
Loading…
Reference in New Issue