@@ -24,7 +24,7 @@ describe('StackTrace', function () {
24
24
describe ( '#get' , function ( ) {
25
25
it ( 'gets stacktrace from current location' , function ( ) {
26
26
runs ( function testStackTraceGet ( ) {
27
- StackTrace . get ( ) . then ( callback , errback ) [ 'catch' ] ( debugErrback ) ;
27
+ StackTrace . get ( ) . then ( callback , errback ) [ 'catch' ] ( errback ) ;
28
28
} ) ;
29
29
waits ( 100 ) ;
30
30
runs ( function ( ) {
@@ -60,7 +60,7 @@ describe('StackTrace', function () {
60
60
runs ( function ( ) {
61
61
server . respondWith ( 'GET' , 'http://path/to/file.js' , [ 404 , { 'Content-Type' : 'text/plain' } , '' ] ) ;
62
62
StackTrace . fromError ( Errors . IE_11 )
63
- . then ( callback , debugErrback ) [ 'catch' ] ( debugErrback ) ;
63
+ . then ( callback , errback ) [ 'catch' ] ( errback ) ;
64
64
server . respond ( ) ;
65
65
} ) ;
66
66
waits ( 100 ) ;
@@ -81,7 +81,7 @@ describe('StackTrace', function () {
81
81
82
82
server . respondWith ( 'GET' , 'http://path/to/file.js' , [ 404 , { 'Content-Type' : 'text/plain' } , '' ] ) ;
83
83
StackTrace . fromError ( Errors . IE_11 , { filter : onlyFoos } )
84
- . then ( callback , debugErrback ) [ 'catch' ] ( debugErrback ) ;
84
+ . then ( callback , errback ) [ 'catch' ] ( errback ) ;
85
85
server . respond ( ) ;
86
86
} ) ;
87
87
waits ( 100 ) ;
@@ -103,7 +103,7 @@ describe('StackTrace', function () {
103
103
server . respondWith ( 'GET' , 'test.js.map' , [ 200 , { 'Content-Type' : 'application/json' } , sourceMap ] ) ;
104
104
105
105
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 ) ;
107
107
server . respond ( ) ;
108
108
} ) ;
109
109
waits ( 100 ) ;
@@ -129,7 +129,7 @@ describe('StackTrace', function () {
129
129
stackFrame . getFunctionName ( ) . indexOf ( 'testGenerateArtificially' ) > - 1 ;
130
130
} ;
131
131
StackTrace . generateArtificially ( { filter : stackFrameFilter } )
132
- . then ( callback , errback ) [ 'catch' ] ( debugErrback ) ;
132
+ . then ( callback , errback ) [ 'catch' ] ( errback ) ;
133
133
} ) ;
134
134
waits ( 100 ) ;
135
135
runs ( function ( ) {
@@ -209,4 +209,47 @@ describe('StackTrace', function () {
209
209
expect ( unwrapped ) . toEqual ( interestingFn ) ;
210
210
} ) ;
211
211
} ) ;
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
+ } ) ;
212
255
} ) ;
0 commit comments