15
15
* limitations under the License.
16
16
*/
17
17
18
- import * as sinon from 'sinon' ;
19
- import { PersistenceType } from '.' ;
20
18
import { expect } from 'chai' ;
21
- import { browserLocalPersistence , browserSessionPersistence } from './browser ' ;
22
- import { User } from '../../model/user' ;
19
+ import * as sinon from 'sinon ' ;
20
+
23
21
import { testUser } from '../../../test/mock_auth' ;
22
+ import { PersistedBlob , PersistenceType } from './' ;
23
+ import { browserLocalPersistence , browserSessionPersistence } from './browser' ;
24
24
25
25
describe ( 'core/persistence/browser' , ( ) => {
26
26
beforeEach ( ( ) => {
@@ -44,16 +44,14 @@ describe('core/persistence/browser', () => {
44
44
expect ( await persistence . get ( key ) ) . to . be . null ;
45
45
} ) ;
46
46
47
- it ( 'should call instantiator function if provided ' , async ( ) => {
47
+ it ( 'should return persistedblob from user ' , async ( ) => {
48
48
const key = 'my-super-special-user' ;
49
49
const value = testUser ( 'some-uid' ) ;
50
50
51
51
expect ( await persistence . get ( key ) ) . to . be . null ;
52
- await persistence . set ( key , value ) ;
53
- const out = await persistence . get < User > ( key , blob =>
54
- testUser ( `test-${ blob . uid } ` )
55
- ) ;
56
- expect ( out ?. uid ) . to . eql ( 'test-some-uid' ) ;
52
+ await persistence . set ( key , value . toPlainObject ( ) ) ;
53
+ const out = await persistence . get < PersistedBlob > ( key ) ;
54
+ expect ( out ! [ 'uid' ] ) . to . eql ( value . uid ) ;
57
55
await persistence . remove ( key ) ;
58
56
expect ( await persistence . get ( key ) ) . to . be . null ;
59
57
} ) ;
@@ -89,16 +87,14 @@ describe('core/persistence/browser', () => {
89
87
expect ( await persistence . get ( key ) ) . to . be . null ;
90
88
} ) ;
91
89
92
- it ( 'should call instantiator function if provided ' , async ( ) => {
90
+ it ( 'should emit blobified persisted user ' , async ( ) => {
93
91
const key = 'my-super-special-user' ;
94
92
const value = testUser ( 'some-uid' ) ;
95
93
96
94
expect ( await persistence . get ( key ) ) . to . be . null ;
97
- await persistence . set ( key , value ) ;
98
- const out = await persistence . get < User > ( key , blob =>
99
- testUser ( `test-${ blob . uid } ` )
100
- ) ;
101
- expect ( out ?. uid ) . to . eql ( 'test-some-uid' ) ;
95
+ await persistence . set ( key , value . toPlainObject ( ) ) ;
96
+ const out = await persistence . get < PersistedBlob > ( key ) ;
97
+ expect ( out ! [ 'uid' ] ) . to . eql ( value . uid ) ;
102
98
await persistence . remove ( key ) ;
103
99
expect ( await persistence . get ( key ) ) . to . be . null ;
104
100
} ) ;
0 commit comments