mock-async-storage
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "mock-async-storage", | ||
"title": "Jest Mock AsyncStorage for react-native", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Its a mock of react-native AsyncStorage for jest tests", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
@@ -52,3 +52,3 @@ <!-- TITLE/ --> | ||
const mockStorage = require('mock-async-storage'); | ||
// or import { mock, release } from 'mock-async-storage/src'; | ||
// or import { mock, release } from 'mock-async-storage'; | ||
// mock(); | ||
@@ -63,1 +63,29 @@ // release(); | ||
``` | ||
Working example: | ||
```JavaScript | ||
import 'react-native'; | ||
import { mock, release } from 'mock-async-storage' | ||
import React from 'react'; | ||
import Index from '../index.android.js'; | ||
// Note: test renderer must be required after react-native. | ||
import renderer from 'react-test-renderer'; | ||
mock() | ||
import { AsyncStorage as storage } from 'react-native' | ||
it('renders correctly', () => { | ||
const tree = renderer.create( | ||
<Index /> | ||
); | ||
}); | ||
it('Mock Async Storage working', async () => { | ||
await storage.setItem('myKey', 'myValue') | ||
const value = await storage.getItem('myKey') | ||
expect(value).toBe('myValue') | ||
}) | ||
``` |
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
90
118889
12
264