Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit 452fd40

Browse files
committed
Make tests deterministic
1 parent 74023d6 commit 452fd40

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

test/cookie.test.js

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,15 @@ var assert = require('proclaim');
44
var cookie = require('../lib').constructor.cookie;
55

66
describe('cookie', function() {
7-
// Use a random key for cookies
8-
// Workaround for flaky concurrent tests on Edge
9-
var testKey;
10-
117
beforeEach(function() {
128
// Just to make sure that
139
// URIError is never thrown here.
1410
document.cookie = 'bad=%';
15-
testKey =
16-
'_' +
17-
Math.random()
18-
.toString(36)
19-
.slice(2);
2011
});
2112

2213
afterEach(function() {
2314
// reset to defaults
2415
cookie.options({});
25-
cookie.remove(testKey);
2616
});
2717

2818
describe('#get', function() {
@@ -31,29 +21,29 @@ describe('cookie', function() {
3121
});
3222

3323
it('should get an existing cookie', function() {
34-
cookie.set(testKey, { a: 'b' });
35-
assert.deepEqual(cookie.get(testKey), { a: 'b' });
24+
cookie.set('cookie-get', { a: 'b' });
25+
assert.deepEqual(cookie.get('cookie-get'), { a: 'b' });
3626
});
3727

3828
it('should not throw an error on a malformed cookie', function() {
39-
document.cookie = testKey + '=y';
40-
assert(cookie.get(testKey) === null);
29+
document.cookie = 'cookie-bad=y';
30+
assert(cookie.get('cookie-bad') === null);
4131
});
4232
});
4333

4434
describe('#set', function() {
4535
it('should set a cookie', function() {
46-
cookie.set(testKey, { a: 'b' });
47-
assert.deepEqual(cookie.get(testKey), { a: 'b' });
36+
cookie.set('cookie-set', { a: 'b' });
37+
assert.deepEqual(cookie.get('cookie-set'), { a: 'b' });
4838
});
4939
});
5040

5141
describe('#remove', function() {
5242
it('should remove a cookie', function() {
53-
cookie.set(testKey, { a: 'b' });
54-
assert.deepEqual(cookie.get(testKey), { a: 'b' });
55-
cookie.remove(testKey);
56-
assert(cookie.get(testKey) === null);
43+
cookie.set('cookie-remove', { a: 'b' });
44+
assert.deepEqual(cookie.get('cookie-remove'), { a: 'b' });
45+
cookie.remove('cookie-remove');
46+
assert(cookie.get('cookie-remove') === null);
5747
});
5848
});
5949

0 commit comments

Comments
 (0)