@@ -3,17 +3,36 @@ import { setAcl, keyAclBody } from '../../../../src/utils/keyHelpers/acl'
33
44store . fetcher . load = jest . fn ( ) . mockImplementation ( ( ) => { } )
55store . any = jest . fn ( )
6+ store . fetcher . webOperation = jest . fn ( )
7+
8+ const keyDoc = 'https://alice.solidcommunity.net/profile/keys/publicKey.ttl'
9+ const keyAclDoc = 'https://alice.solidcommunity.net/profile/keys/publicKey.ttl'
10+ const error404 = {
11+ response : {
12+ status : 404
13+ }
14+ }
615
716describe ( 'ACL Helpers' , ( ) => {
817 describe ( 'setAcl' , ( ) => {
918 it ( 'throws an error if an ACL document is NOT found' , async ( ) => {
1019 /* @ts -ignore */
11- store . any . mockReturnValue ( '' )
12- const keyDoc = 'https://alice.solidcommunity.net/profile/keys/publicKey.ttl'
20+ store . any . mockReturnValueOnce ( '' )
1321 await expect ( setAcl ( keyDoc , keyAclBody ( keyDoc , '' ) ) ) . rejects . toThrowError ( 'Key ACL doc not found!' )
1422 } )
15- it . skip ( 'want to find out why we delete and then re-add' , ( ) => {
16-
23+ it ( 'throws error if acl can not be written' , async ( ) => {
24+ /* @ts -ignore */
25+ store . any . mockReturnValueOnce ( keyAclDoc )
26+ /* @ts -ignore */
27+ store . fetcher . webOperation . mockRejectedValueOnce ( )
28+ await expect ( setAcl ( keyDoc , keyAclBody ( keyDoc , '' ) ) ) . rejects . toThrowError ( '' )
29+ } )
30+ it ( 'continues if error is because acl doc can not be found.' , async ( ) => {
31+ /* @ts -ignore */
32+ store . any . mockReturnValueOnce ( keyAclDoc )
33+ /* @ts -ignore */
34+ store . fetcher . webOperation . mockRejectedValueOnce ( error404 )
35+ await expect ( setAcl ( keyDoc , keyAclBody ( keyDoc , '' ) ) ) . resolves . toBeUndefined
1736 } )
1837 } )
1938} )
0 commit comments