@@ -24,7 +24,7 @@ describe('StackTrace', function () {
2424 describe ( '#get' , function ( ) {
2525 it ( 'gets stacktrace from current location' , function ( ) {
2626 runs ( function testStackTraceGet ( ) {
27- StackTrace . get ( ) . then ( callback , errback ) [ 'catch' ] ( debugErrback ) ;
27+ StackTrace . get ( ) . then ( callback , errback ) [ 'catch' ] ( errback ) ;
2828 } ) ;
2929 waits ( 100 ) ;
3030 runs ( function ( ) {
@@ -60,7 +60,7 @@ describe('StackTrace', function () {
6060 runs ( function ( ) {
6161 server . respondWith ( 'GET' , 'http://path/to/file.js' , [ 404 , { 'Content-Type' : 'text/plain' } , '' ] ) ;
6262 StackTrace . fromError ( Errors . IE_11 )
63- . then ( callback , debugErrback ) [ 'catch' ] ( debugErrback ) ;
63+ . then ( callback , errback ) [ 'catch' ] ( errback ) ;
6464 server . respond ( ) ;
6565 } ) ;
6666 waits ( 100 ) ;
@@ -81,7 +81,7 @@ describe('StackTrace', function () {
8181
8282 server . respondWith ( 'GET' , 'http://path/to/file.js' , [ 404 , { 'Content-Type' : 'text/plain' } , '' ] ) ;
8383 StackTrace . fromError ( Errors . IE_11 , { filter : onlyFoos } )
84- . then ( callback , debugErrback ) [ 'catch' ] ( debugErrback ) ;
84+ . then ( callback , errback ) [ 'catch' ] ( errback ) ;
8585 server . respond ( ) ;
8686 } ) ;
8787 waits ( 100 ) ;
@@ -103,7 +103,7 @@ describe('StackTrace', function () {
103103 server . respondWith ( 'GET' , 'test.js.map' , [ 200 , { 'Content-Type' : 'application/json' } , sourceMap ] ) ;
104104
105105 var stack = 'TypeError: Unable to get property \'undef\' of undefined or null reference\n at foo (http://path/to/file.js:45:13)' ;
106- StackTrace . fromError ( { stack : stack } ) . then ( callback , errback ) [ 'catch' ] ( debugErrback ) ;
106+ StackTrace . fromError ( { stack : stack } ) . then ( callback , errback ) [ 'catch' ] ( errback ) ;
107107 server . respond ( ) ;
108108 } ) ;
109109 waits ( 100 ) ;
@@ -129,7 +129,7 @@ describe('StackTrace', function () {
129129 stackFrame . getFunctionName ( ) . indexOf ( 'testGenerateArtificially' ) > - 1 ;
130130 } ;
131131 StackTrace . generateArtificially ( { filter : stackFrameFilter } )
132- . then ( callback , errback ) [ 'catch' ] ( debugErrback ) ;
132+ . then ( callback , errback ) [ 'catch' ] ( errback ) ;
133133 } ) ;
134134 waits ( 100 ) ;
135135 runs ( function ( ) {
@@ -209,4 +209,47 @@ describe('StackTrace', function () {
209209 expect ( unwrapped ) . toEqual ( interestingFn ) ;
210210 } ) ;
211211 } ) ;
212+
213+ describe ( '#report' , function ( ) {
214+ var server ;
215+ beforeEach ( function ( ) {
216+ server = sinon . fakeServer . create ( ) ;
217+ } ) ;
218+ afterEach ( function ( ) {
219+ server . restore ( ) ;
220+ } ) ;
221+
222+ it ( 'sends POST request to given URL' , function ( ) {
223+ var url = 'http://domain.ext/endpoint' ;
224+ var stackframes = [ new StackFrame ( 'fn' , undefined , 'file.js' , 32 , 1 ) ] ;
225+
226+ runs ( function ( ) {
227+ server . respondWith ( 'POST' , url , [ 201 , { 'Content-Type' : 'text/plain' } , 'OK' ] ) ;
228+ StackTrace . report ( stackframes , url ) . then ( callback , errback ) [ 'catch' ] ( errback ) ;
229+ server . respond ( ) ;
230+ } ) ;
231+ waits ( 100 ) ;
232+ runs ( function ( ) {
233+ expect ( server . requests [ 0 ] . requestBody ) . toEqual ( { stack : stackframes } ) ;
234+ expect ( server . requests [ 0 ] . url ) . toEqual ( url ) ;
235+ expect ( callback ) . toHaveBeenCalledWith ( 'OK' ) ;
236+ expect ( errback ) . not . toHaveBeenCalled ( ) ;
237+ } ) ;
238+ } ) ;
239+
240+ it ( 'rejects if POST request fails' , function ( ) {
241+ runs ( function ( ) {
242+ var url = 'http://domain.ext/endpoint' ;
243+ var stackframes = [ new StackFrame ( 'fn' , undefined , 'file.js' , 32 , 1 ) ] ;
244+ server . respondWith ( 'POST' , url , [ 404 , { 'Content-Type' : 'text/plain' } , '' ] ) ;
245+ StackTrace . report ( stackframes , url ) . then ( callback , errback ) [ 'catch' ] ( errback ) ;
246+ server . respond ( ) ;
247+ } ) ;
248+ waits ( 100 ) ;
249+ runs ( function ( ) {
250+ expect ( callback ) . not . toHaveBeenCalled ( ) ;
251+ expect ( errback ) . toHaveBeenCalled ( ) ;
252+ } ) ;
253+ } ) ;
254+ } ) ;
212255} ) ;
0 commit comments