jest-localstorage-mock
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -34,1 +34,28 @@ beforeEach(() => { | ||
}); | ||
test('localstorage set and remove', () => { | ||
const KEY = 'foo', VALUE = 'bar'; | ||
localStorage.setItem(KEY, VALUE); | ||
expect(localStorage.getItem(KEY)).toBe(VALUE); | ||
localStorage.removeItem(KEY); | ||
expect(localStorage.getItem(KEY)).toBeNull(); | ||
}); | ||
test('localstorage set and remove', () => { | ||
const KEY1 = 'foo', VALUE = 'bar', KEY2 = 'baz'; | ||
localStorage.setItem(KEY1, VALUE); | ||
expect(localStorage.getItem(KEY1)).toBe(VALUE); | ||
expect(localStorage.length).toBe(1); | ||
localStorage.setItem(KEY2, VALUE); | ||
expect(localStorage.getItem(KEY2)).toBe(VALUE); | ||
expect(localStorage.length).toBe(2); | ||
}); | ||
test('localstorage.key', () => { | ||
const KEY = 'foo', VALUE = 'bar'; | ||
localStorage.setItem(KEY, VALUE); | ||
expect(localStorage.getItem(KEY)).toBe(VALUE); | ||
expect(localStorage.key(0)).toBe(KEY); | ||
expect(localStorage.length).toBe(1); | ||
expect(localStorage.key(1)).toBeNull(); | ||
}); |
@@ -57,2 +57,8 @@ 'use strict'; | ||
}, { | ||
key: 'key', | ||
value: function key(index) { | ||
var keys = Object.keys(this.store); | ||
return keys[index] || null; | ||
} | ||
}, { | ||
key: 'length', | ||
@@ -59,0 +65,0 @@ get: function get$$1() { |
{ | ||
"name": "jest-localstorage-mock", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Mock localstorage in your Jest tests", | ||
@@ -20,3 +20,3 @@ "main": "dist/setup.js", | ||
"eslint": "^3.19.0", | ||
"eslint-config-prettier": "^1.7.0", | ||
"eslint-config-prettier": "^2.0.0", | ||
"eslint-plugin-prettier": "^2.0.1", | ||
@@ -23,0 +23,0 @@ "jest": "^20.0.0", |
@@ -1,6 +0,4 @@ | ||
[![npm](https://img.shields.io/npm/v/jest-localstorage-mock.svg)](https://www.npmjs.com/package/jest-localstorage-mock) | [![npm](https://img.shields.io/npm/l/jest-localstorage-mock.svg)](https://github.com/clarkbw/jest-localstorage-mock/blob/master/LICENSE) | [![Twitter](https://img.shields.io/twitter/url/https/github.com/clarkbw/jest-localstorage-mock.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=%5Bobject%20Object%5D) | ||
[![npm](https://img.shields.io/npm/v/jest-localstorage-mock.svg)](https://www.npmjs.com/package/jest-localstorage-mock) | [![npm](https://img.shields.io/npm/l/jest-localstorage-mock.svg)](https://github.com/clarkbw/jest-localstorage-mock/blob/master/LICENSE) | [![Codecov](https://img.shields.io/codecov/c/github/clarkbw/jest-localstorage-mock.svg)](https://codecov.io/gh/clarkbw/jest-localstorage-mock) | [![Greenkeeper badge](https://badges.greenkeeper.io/clarkbw/jest-localstorage-mock.svg)](https://greenkeeper.io/) | [![Twitter](https://img.shields.io/twitter/url/https/github.com/clarkbw/jest-localstorage-mock.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=%5Bobject%20Object%5D) | ||
---|--- | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/clarkbw/jest-localstorage-mock.svg)](https://greenkeeper.io/) | ||
## Install | ||
@@ -7,0 +5,0 @@ |
@@ -22,2 +22,7 @@ export class LocalStorage { | ||
key(index) { | ||
const keys = Object.keys(this.store); | ||
return keys[index] || null; | ||
} | ||
get length() { | ||
@@ -24,0 +29,0 @@ return Object.keys(this.store).length; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116246
159
79