Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-localstorage-mock

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-localstorage-mock - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

27

__tests__/index.js

@@ -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() {

4

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc