Skip to content

Commit a55ee6c

Browse files
Justin SisleyJustin Sisley
Justin Sisley
authored and
Justin Sisley
committedApr 13, 2019
build: Updated dependencies and fixed tests
1 parent 3caed6e commit a55ee6c

File tree

4 files changed

+50
-53
lines changed

4 files changed

+50
-53
lines changed
 

‎.npmrc

-1
This file was deleted.

‎browser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var tokenpress = {
2323
get: function get() {
2424
return window[storage].getItem(config.storageKey);
2525
},
26-
delete: function _delete() {
26+
"delete": function _delete() {
2727
window[storage].removeItem(config.storageKey);
2828
},
2929
isExpired: function isExpired() {

‎package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
"author": "Justin Sisley",
1616
"license": "MIT",
1717
"dependencies": {
18-
"jsonwebtoken": "^8.3.0"
18+
"jsonwebtoken": "^8.5.1"
1919
},
2020
"devDependencies": {
21-
"@babel/cli": "^7.0.0",
22-
"@babel/core": "^7.0.1",
23-
"@babel/preset-env": "^7.0.0",
21+
"@babel/cli": "^7.4.3",
22+
"@babel/core": "^7.4.3",
23+
"@babel/preset-env": "^7.4.3",
2424
"babel-core": "^7.0.0-bridge.0",
2525
"dutchie": "^1.2.0",
26-
"eslint": "^4.19.1",
26+
"eslint": "^5.16.0",
2727
"eslint-config-airbnb-base": "^13.1.0",
28-
"eslint-plugin-import": "^2.14.0",
29-
"jest": "^23.6.0"
28+
"eslint-plugin-import": "^2.16.0",
29+
"jest": "^24.7.1"
3030
},
3131
"babel": {
3232
"presets": [
@@ -42,4 +42,4 @@
4242
"window": true
4343
}
4444
}
45-
}
45+
}

‎test.js

+41-43
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,58 @@
11
const browser = require('./lib/browser');
22
const node = require('./lib/node');
33

4-
describe('browser', () => {
5-
it('should export an object', () => {
6-
expect(typeof browser).toBe('object');
7-
});
8-
9-
it('should allow the localStorage key to be customized', () => {
10-
const sampleToken = '12345';
4+
it('should export an object', () => {
5+
expect(typeof browser).toBe('object');
6+
});
117

12-
// Save to the default key
13-
browser.save(sampleToken);
8+
it('should allow the localStorage key to be customized', () => {
9+
const sampleToken = '12345';
1410

15-
// Change the key
16-
browser.configure({
17-
localStorageKey: 'test-key',
18-
});
11+
// Save to the default key
12+
browser.save(sampleToken);
1913

20-
// No token exists for the new key
21-
expect(browser.get()).toBe(null);
14+
// Change the key
15+
browser.configure({
16+
localStorageKey: 'test-key',
17+
});
2218

23-
// Save under the new key and verify
24-
browser.save(sampleToken);
25-
expect(browser.get()).toBe(sampleToken);
19+
// No token exists for the new key
20+
expect(browser.get()).toBe(null);
2621

27-
// Cleanup
28-
browser.delete();
29-
});
22+
// Save under the new key and verify
23+
browser.save(sampleToken);
24+
expect(browser.get()).toBe(sampleToken);
3025

31-
it('should save, get, and delete tokens', () => {
32-
const sampleToken = '12345';
26+
// Cleanup
27+
browser.delete();
28+
});
3329

34-
// Should not exist yet
35-
expect(browser.get()).toBe(null);
30+
it('should save, get, and delete tokens', () => {
31+
const sampleToken = '12345';
3632

37-
// Save it and verify it's there
38-
browser.save(sampleToken);
39-
expect(browser.get()).toBe(sampleToken);
33+
// Should not exist yet
34+
expect(browser.get()).toBe(null);
4035

41-
// Delete it and verify it's gone
42-
browser.delete();
43-
expect(browser.get()).toBe(null);
44-
});
36+
// Save it and verify it's there
37+
browser.save(sampleToken);
38+
expect(browser.get()).toBe(sampleToken);
4539

46-
it('should verify if a token has expired', async (done) => {
47-
// Configure with a 1-second expiration
48-
node.configure({
49-
secret: 'test',
50-
expiresIn: 1,
51-
});
40+
// Delete it and verify it's gone
41+
browser.delete();
42+
expect(browser.get()).toBe(null);
43+
});
5244

53-
// Create a new token
54-
const token = await node.jwt.sign({
55-
username: 'test_username',
56-
});
45+
it('should verify if a token has expired', (done) => {
46+
// Configure with a 1-second expiration
47+
node.configure({
48+
secret: 'test',
49+
expiresIn: 1,
50+
});
5751

52+
// Create a new token
53+
node.jwt.sign({
54+
username: 'test_username',
55+
}).then((token) => {
5856
// Save it to localStorage
5957
browser.save(token);
6058

@@ -63,7 +61,7 @@ describe('browser', () => {
6361
expect(browser.isExpired(token)).toBe(false);
6462

6563
setTimeout(() => {
66-
// It should now be expired
64+
// It should now be expired
6765
expect(browser.isExpired()).toBe(true);
6866
expect(browser.isExpired(token)).toBe(true);
6967

0 commit comments

Comments
 (0)
Please sign in to comment.