Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/* eslint-env node */
'use strict';

// 10 minutes
var TEST_TIMEOUT = 10 * 60 * 1000;

module.exports = function(config) {
config.set({
files: [
{ pattern: 'test/support/*.html', included: false },
'test/support/global.js', // NOTE: This must run before all tests
'test/**/*.test.js'
],

browsers: ['PhantomJS'],

frameworks: ['browserify', 'mocha'],
Expand All @@ -19,9 +21,12 @@ module.exports = function(config) {
'test/**/*.js': 'browserify'
},

browserNoActivityTimeout: TEST_TIMEOUT,

client: {
mocha: {
grep: process.env.GREP
grep: process.env.GREP,
timeout: TEST_TIMEOUT
}
},

Expand Down
32 changes: 14 additions & 18 deletions test/cookie.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ describe('cookie', function() {
// Just to make sure that
// URIError is never thrown here.
document.cookie = 'bad=%';

// enable debugging for cookie package so we can better
// observe flaky tests on IE/Edge.
window.localStorage.setItem('debug', 'cookie');
});

afterEach(function() {
// reset to defaults
cookie.options({});
cookie.remove('x');
// remove all cookies
document.cookie.split(';').forEach(function(entry) {
cookie.remove(entry.split('=')[0]);
});
});

describe('#get', function() {
Expand All @@ -26,32 +25,29 @@ describe('cookie', function() {
});

it('should get an existing cookie', function() {
cookie.set('x', { a: 'b' });
assert.deepEqual(cookie.get('x'), { a: 'b' });
cookie.set('cookie-get', { a: 'b' });
assert.deepEqual(cookie.get('cookie-get'), { a: 'b' });
});

it('should not throw an error on a malformed cookie', function() {
document.cookie = 'x=y';
assert(cookie.get('x') === null);
document.cookie = 'cookie-bad=y';
assert(cookie.get('cookie-bad') === null);
});
});

describe('#set', function() {
it('should set a cookie', function() {
// Logging so we can better observe flaky tests on IE/Edge.
console.log('setting cookie. document.cookie is', document.cookie);
cookie.set('x', { a: 'b' });
console.log('cookie set. document.cookie is', document.cookie);
assert.deepEqual(cookie.get('x'), { a: 'b' });
cookie.set('cookie-set', { a: 'b' });
assert.deepEqual(cookie.get('cookie-set'), { a: 'b' });
});
});

describe('#remove', function() {
it('should remove a cookie', function() {
cookie.set('x', { a: 'b' });
assert.deepEqual(cookie.get('x'), { a: 'b' });
cookie.remove('x');
assert(cookie.get('x') === null);
cookie.set('cookie-remove', { a: 'b' });
assert.deepEqual(cookie.get('cookie-remove'), { a: 'b' });
cookie.remove('cookie-remove');
assert(cookie.get('cookie-remove') === null);
});
});

Expand Down