@@ -63,6 +63,17 @@ describe('DeleteHandler tests', function() {
6363 expect ( fakeServer . requests . length ) . toEqual ( 0 ) ;
6464 } ) ;
6565 it ( 'deletes first entry and reshows notification on second delete' , function ( ) {
66+ fakeServer . respondWith ( / \/ i n d e x \. p h p \/ d u m m y e n d p o i n t .p h p \/ s o m e _ u i d / , [
67+ 204 ,
68+ { 'Content-Type' : 'application/json' } ,
69+ JSON . stringify ( { status : 'success' } )
70+ ] ) ;
71+ fakeServer . respondWith ( / \/ i n d e x \. p h p \/ d u m m y e n d p o i n t .p h p \/ s o m e _ o t h e r _ u i d / , [
72+ 204 ,
73+ { 'Content-Type' : 'application/json' } ,
74+ JSON . stringify ( { status : 'success' } )
75+ ] ) ;
76+
6677 var handler = init ( markCallback , removeCallback , undoCallback ) ;
6778 handler . mark ( 'some_uid' ) ;
6879
@@ -79,7 +90,8 @@ describe('DeleteHandler tests', function() {
7990 expect ( markCallback . calledTwice ) . toEqual ( true ) ;
8091 expect ( markCallback . getCall ( 0 ) . args [ 0 ] ) . toEqual ( 'some_uid' ) ;
8192 expect ( markCallback . getCall ( 1 ) . args [ 0 ] ) . toEqual ( 'some_other_uid' ) ;
82- expect ( removeCallback . notCalled ) . toEqual ( true ) ;
93+ // called only once, because it is called once the second user is deleted
94+ expect ( removeCallback . calledOnce ) . toEqual ( true ) ;
8395 expect ( undoCallback . notCalled ) . toEqual ( true ) ;
8496
8597 // previous one was delete
@@ -88,6 +100,12 @@ describe('DeleteHandler tests', function() {
88100 expect ( request . url ) . toEqual ( OC . webroot + '/index.php/dummyendpoint.php/some_uid' ) ;
89101 } ) ;
90102 it ( 'automatically deletes after timeout' , function ( ) {
103+ fakeServer . respondWith ( / \/ i n d e x \. p h p \/ d u m m y e n d p o i n t .p h p \/ s o m e _ u i d / , [
104+ 204 ,
105+ { 'Content-Type' : 'application/json' } ,
106+ JSON . stringify ( { status : 'success' } )
107+ ] ) ;
108+
91109 var handler = init ( markCallback , removeCallback , undoCallback ) ;
92110 handler . mark ( 'some_uid' ) ;
93111
@@ -101,6 +119,11 @@ describe('DeleteHandler tests', function() {
101119 expect ( request . url ) . toEqual ( OC . webroot + '/index.php/dummyendpoint.php/some_uid' ) ;
102120 } ) ;
103121 it ( 'deletes when deleteEntry is called' , function ( ) {
122+ fakeServer . respondWith ( / \/ i n d e x \. p h p \/ d u m m y e n d p o i n t .p h p \/ s o m e _ u i d / , [
123+ 200 ,
124+ { 'Content-Type' : 'application/json' } ,
125+ JSON . stringify ( { status : 'success' } )
126+ ] ) ;
104127 var handler = init ( markCallback , removeCallback , undoCallback ) ;
105128 handler . mark ( 'some_uid' ) ;
106129
@@ -157,7 +180,7 @@ describe('DeleteHandler tests', function() {
157180 // stub t to avoid extra calls
158181 var tStub = sinon . stub ( window , 't' ) . returns ( 'text' ) ;
159182 fakeServer . respondWith ( / \/ i n d e x \. p h p \/ d u m m y e n d p o i n t .p h p \/ s o m e _ u i d / , [
160- 200 ,
183+ 403 ,
161184 { 'Content-Type' : 'application/json' } ,
162185 JSON . stringify ( { status : 'error' , data : { message : 'test error' } } )
163186 ] ) ;
0 commit comments