@@ -25,44 +25,28 @@ describe('storageHandler', () => {
2525 it ( 'implements getItem' , async ( ) => {
2626 expect . assertions ( 1 )
2727 await store . setItem ( 'foo' , 'bar' )
28- const resp = await handler ( {
29- id : '12345' ,
30- method : 'storage/getItem' ,
31- args : [ 'foo' ]
32- } )
33- expect ( resp ) . toEqual ( { id : '12345' , ret : 'bar' } )
28+ const resp = await handler ( 'storage/getItem' , 'foo' )
29+ expect ( resp ) . toEqual ( 'bar' )
3430 } )
3531
3632 it ( 'implements setItem' , async ( ) => {
3733 expect . assertions ( 2 )
38- const resp = await handler ( {
39- id : '12345' ,
40- method : 'storage/setItem' ,
41- args : [ 'foo' , 'bar' ]
42- } )
43- expect ( resp ) . toEqual ( { id : '12345' , ret : null } )
34+ const resp = await handler ( 'storage/setItem' , 'foo' , 'bar' )
35+ expect ( resp ) . toEqual ( undefined )
4436 expect ( await store . getItem ( 'foo' ) ) . toEqual ( 'bar' )
4537 } )
4638
4739 it ( 'implements removeItem' , async ( ) => {
4840 expect . assertions ( 2 )
4941 await store . setItem ( 'foo' , 'bar' )
50- const resp = await handler ( {
51- id : '12345' ,
52- method : 'storage/removeItem' ,
53- args : [ 'foo' ]
54- } )
55- expect ( resp ) . toEqual ( { id : '12345' , ret : null } )
42+ const resp = await handler ( 'storage/removeItem' , 'foo' )
43+ expect ( resp ) . toEqual ( undefined )
5644 expect ( await store . getItem ( 'foo' ) ) . toEqual ( null )
5745 } )
5846
5947 it ( 'ignores unknown methods' , async ( ) => {
6048 expect . assertions ( 1 )
61- const resp = await handler ( {
62- id : '12345' ,
63- method : 'unknown_method' ,
64- args : [ 'a' , 'b' , 'c' ]
65- } )
49+ const resp = await handler ( 'unknown_method' , 'a' , 'b' , 'c' )
6650 expect ( resp ) . toBeNull ( )
6751 } )
6852} )
@@ -77,17 +61,10 @@ describe('loginHandler', () => {
7761 it ( 'returns the loginOptions' , async ( ) => {
7862 expect . assertions ( 1 )
7963 const handler = loginHandler ( options , ( ) => { } )
80- const _options = await handler ( {
81- id : '12345' ,
82- method : 'getLoginOptions' ,
83- args : [ ]
84- } )
64+ const _options = await handler ( 'getLoginOptions' )
8565 expect ( _options ) . toEqual ( {
86- id : '12345' ,
87- ret : {
88- popupUri : options . popupUri ,
89- callbackUri : options . callbackUri
90- }
66+ popupUri : options . popupUri ,
67+ callbackUri : options . callbackUri
9168 } )
9269 } )
9370
@@ -99,52 +76,30 @@ describe('loginHandler', () => {
9976 idp : 'https://example.com' ,
10077 webId : 'https://me.example.com/profile#me'
10178 }
102- const _sessionResp = await handler ( {
103- id : '12345' ,
104- method : 'foundSession' ,
105- args : [ session ]
106- } )
107- expect ( _sessionResp ) . toEqual ( {
108- id : '12345' ,
109- ret : null
110- } )
79+ const _sessionResp = await handler ( 'foundSession' , session )
80+ expect ( _sessionResp ) . toEqual ( null )
11181 expect ( mockCallback . mock . calls . length ) . toBe ( 1 )
11282 expect ( mockCallback . mock . calls [ 0 ] [ 0 ] ) . toEqual ( session )
11383 } )
11484
11585 it ( 'ignores unknown methods' , async ( ) => {
11686 expect . assertions ( 1 )
11787 const handler = loginHandler ( options , ( ) => { } )
118- const resp = await handler ( {
119- id : '12345' ,
120- method : 'unknown_method' ,
121- args : [ 'a' , 'b' , 'c' ]
122- } )
88+ const resp = await handler ( 'unknown_method' , 'a' , 'b' , 'c' )
12389 expect ( resp ) . toBeNull ( )
12490 } )
12591} )
12692
12793describe ( 'appOriginHandler' , ( ) => {
12894 it ( 'responds with the window origin' , async ( ) => {
12995 expect . assertions ( 1 )
130- const resp = await appOriginHandler ( {
131- id : '12345' ,
132- method : 'getAppOrigin' ,
133- args : [ ]
134- } )
135- expect ( resp ) . toEqual ( {
136- id : '12345' ,
137- ret : 'https://app.biz'
138- } )
96+ const resp = await appOriginHandler ( 'getAppOrigin' )
97+ expect ( resp ) . toEqual ( 'https://app.biz' )
13998 } )
14099
141100 it ( 'ignores unknown methods' , async ( ) => {
142101 expect . assertions ( 1 )
143- const resp = await appOriginHandler ( {
144- id : '12345' ,
145- method : 'somethingCompletelyDifferent' ,
146- args : [ ]
147- } )
102+ const resp = await appOriginHandler ( 'unknown_method' )
148103 expect ( resp ) . toBeNull ( )
149104 } )
150105} )
0 commit comments