Skip to content

Commit c04cb0c

Browse files
Merge pull request #17 from oximer/master
Mock implementation for making jest testing easy
2 parents ad37a49 + 419689d commit c04cb0c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ RNSecureKeyStore.remove("key1")
7676
```
7777
- For demo app, checkout example directory.
7878

79+
## Testing
80+
81+
For Testing using Jest, add RNSecureKeyStoreMock implementation under your __test__/__mocks__ folder.
82+
This mock implementation makes easy for you to make testing that dependes on react-native-secure-key-store
83+
7984
## License
8085

8186
ISC License (ISC)

example/RNSecureKeyStoreMock

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class RNSecureKeyStoreMock {
2+
store;
3+
4+
constructor() {
5+
this.store = new Map();
6+
}
7+
8+
get(k) {
9+
const result = this.store.get(k);
10+
return Promise.resolve(result);
11+
}
12+
13+
remove(k) {
14+
this.store.delete(k);
15+
return Promise.resolve(true);
16+
}
17+
18+
set(k, value) {
19+
console.log('set', k, value);
20+
21+
this.store.set(k, value);
22+
return Promise.resolve(true);
23+
}
24+
}
25+
26+
const RNSecureKeyStore = new RNSecureKeyStoreMock();
27+
28+
export default RNSecureKeyStore;

0 commit comments

Comments
 (0)