@@ -23,57 +23,41 @@ describe('reactNativeAsyncStorageCache', () => {
2323 cacheInstance = new ReactNativeAsyncStorageCache ( )
2424 } )
2525
26- describe ( 'get' , function ( ) {
27- it ( 'should return correct object when item is found in cache' , function ( done ) {
28- cacheInstance . get ( 'keyThatExists' )
29- . then ( v => {
30- expect ( v ) . toEqual ( { name : "Awesome Object" } )
31- done ( )
32- } )
26+ describe ( 'get' , function ( ) {
27+ it ( 'should return correct object when item is found in cache' , function ( ) {
28+ return cacheInstance . get ( 'keyThatExists' )
29+ . then ( v => expect ( v ) . toEqual ( { name : "Awesome Object" } ) )
3330 } )
3431
35- it ( 'should return null if item is not found in cache' , function ( done ) {
36- cacheInstance . get ( 'keyThatDoesNotExist' )
37- . then ( v => {
38- expect ( v ) . toBeNull ( )
39- done ( )
40- } )
32+ it ( 'should return null if item is not found in cache' , function ( ) {
33+ return cacheInstance . get ( 'keyThatDoesNotExist' ) . then ( v => expect ( v ) . toBeNull ( ) )
4134 } )
4235
43- it ( 'should reject promise error if string has an incorrect JSON format' , function ( done ) {
44- cacheInstance . get ( 'keyWithInvalidJsonObject' )
45- . catch ( e => {
46- done ( )
47- } )
36+ it ( 'should reject promise error if string has an incorrect JSON format' , function ( ) {
37+ return cacheInstance . get ( 'keyWithInvalidJsonObject' ) . catch ( ( ) => { } )
4838 } )
4939 } )
5040
5141 describe ( 'set' , function ( ) {
52- it ( 'should resolve promise if item was successfully set in the cache' , function ( done ) {
42+ it ( 'should resolve promise if item was successfully set in the cache' , function ( ) {
5343 const testObj = { name : "Awesome Object" }
54- cacheInstance . set ( 'testKey' , testObj ) . then ( ( ) => done ( ) )
44+ return cacheInstance . set ( 'testKey' , testObj )
5545 } )
5646
57- it ( 'should reject promise if item was not set in the cache because of json stringifying error' , function ( done ) {
47+ it ( 'should reject promise if item was not set in the cache because of json stringifying error' , function ( ) {
5848 const testObj : any = { name : "Awesome Object" }
5949 testObj . myOwnReference = testObj
60- cacheInstance . set ( 'testKey' , testObj ) . catch ( ( ) => done ( ) )
50+ return cacheInstance . set ( 'testKey' , testObj ) . catch ( ( ) => { } )
6151 } )
6252 } )
6353
64- describe ( 'contains' , function ( ) {
65- it ( 'should return true if object with key exists' , function ( done ) {
66- cacheInstance . contains ( 'keyThatExists' ) . then ( v => {
67- expect ( v ) . toBeTruthy ( )
68- done ( )
69- } )
54+ describe ( 'contains' , function ( ) {
55+ it ( 'should return true if object with key exists' , function ( ) {
56+ return cacheInstance . contains ( 'keyThatExists' ) . then ( v => expect ( v ) . toBeTruthy ( ) )
7057 } )
7158
72- it ( 'should return false if object with key does not exist' , function ( done ) {
73- cacheInstance . contains ( 'keyThatDoesNotExist' ) . then ( v => {
74- expect ( v ) . toBeFalsy ( )
75- done ( )
76- } )
59+ it ( 'should return false if object with key does not exist' , function ( ) {
60+ return cacheInstance . contains ( 'keyThatDoesNotExist' ) . then ( v => expect ( v ) . toBeFalsy ( ) )
7761 } )
7862 } )
7963} )
0 commit comments