@@ -38,6 +38,14 @@ describe('get', () => {
3838 const state = new StateStore ( true )
3939 await global . expectToThrowBadArg ( state . get . bind ( state , 123 ) , [ 'string' , 'key' ] , { key : 123 } )
4040 } )
41+ // eslint-disable-next-line jest/expect-expect
42+ test ( 'bad key characters' , async ( ) => {
43+ const state = new StateStore ( true )
44+ await global . expectToThrowBadArg ( state . put . bind ( state , '?test' , 'value' , { } ) , [ 'Key' , 'cannot' , 'contain' ] , { key : '?test' , value : 'value' , options : { } } )
45+ await global . expectToThrowBadArg ( state . put . bind ( state , 't#est' , 'value' , { } ) , [ 'Key' , 'cannot' , 'contain' ] , { key : 't#est' , value : 'value' , options : { } } )
46+ await global . expectToThrowBadArg ( state . put . bind ( state , 't\\est' , 'value' , { } ) , [ 'Key' , 'cannot' , 'contain' ] , { key : 't\\est' , value : 'value' , options : { } } )
47+ await global . expectToThrowBadArg ( state . put . bind ( state , 'test/' , 'value' , { } ) , [ 'Key' , 'cannot' , 'contain' ] , { key : 'test/' , value : 'value' , options : { } } )
48+ } )
4149 test ( 'calls _get (part of interface)' , async ( ) => {
4250 const state = new StateStore ( true )
4351 state . _get = jest . fn ( )
@@ -60,6 +68,14 @@ describe('put', () => {
6068 await global . expectToThrowBadArg ( state . put . bind ( state , 123 , 'value' , { } ) , [ 'string' , 'key' ] , { key : 123 , value : 'value' , options : { } } )
6169 } )
6270 // eslint-disable-next-line jest/expect-expect
71+ test ( 'bad key characters' , async ( ) => {
72+ const state = new StateStore ( true )
73+ await global . expectToThrowBadArg ( state . put . bind ( state , '?test' , 'value' , { } ) , [ 'Key' , 'cannot' , 'contain' ] , { key : '?test' , value : 'value' , options : { } } )
74+ await global . expectToThrowBadArg ( state . put . bind ( state , 't#est' , 'value' , { } ) , [ 'Key' , 'cannot' , 'contain' ] , { key : 't#est' , value : 'value' , options : { } } )
75+ await global . expectToThrowBadArg ( state . put . bind ( state , 't\\est' , 'value' , { } ) , [ 'Key' , 'cannot' , 'contain' ] , { key : 't\\est' , value : 'value' , options : { } } )
76+ await global . expectToThrowBadArg ( state . put . bind ( state , 'test/' , 'value' , { } ) , [ 'Key' , 'cannot' , 'contain' ] , { key : 'test/' , value : 'value' , options : { } } )
77+ } )
78+ // eslint-disable-next-line jest/expect-expect
6379 test ( 'bad options' , async ( ) => {
6480 const state = new StateStore ( true )
6581 const expectedDetails = { key : 'key' , value : 'value' }
@@ -102,6 +118,14 @@ describe('delete', () => {
102118 const state = new StateStore ( true )
103119 await global . expectToThrowBadArg ( state . delete . bind ( state , 123 ) , [ 'string' , 'key' ] , { key : 123 } )
104120 } )
121+ // eslint-disable-next-line jest/expect-expect
122+ test ( 'bad key characters' , async ( ) => {
123+ const state = new StateStore ( true )
124+ await global . expectToThrowBadArg ( state . put . bind ( state , '?test' , 'value' , { } ) , [ 'Key' , 'cannot' , 'contain' ] , { key : '?test' , value : 'value' , options : { } } )
125+ await global . expectToThrowBadArg ( state . put . bind ( state , 't#est' , 'value' , { } ) , [ 'Key' , 'cannot' , 'contain' ] , { key : 't#est' , value : 'value' , options : { } } )
126+ await global . expectToThrowBadArg ( state . put . bind ( state , 't\\est' , 'value' , { } ) , [ 'Key' , 'cannot' , 'contain' ] , { key : 't\\est' , value : 'value' , options : { } } )
127+ await global . expectToThrowBadArg ( state . put . bind ( state , 'test/' , 'value' , { } ) , [ 'Key' , 'cannot' , 'contain' ] , { key : 'test/' , value : 'value' , options : { } } )
128+ } )
105129 test ( 'calls _delete (part of interface)' , async ( ) => {
106130 const state = new StateStore ( true )
107131 state . _delete = jest . fn ( )
0 commit comments