1- import { Transport } from '@sentry/types' ;
21import { expect } from 'chai' ;
32import { SinonStub , stub } from 'sinon' ;
4- import { FetchTransport } from '../../src/transports/fetch ' ;
3+ import { Status , Transports } from '../../src' ;
54
65const testDSN = 'https://123@sentry.io/42' ;
76const transportUrl =
@@ -15,12 +14,12 @@ const payload = {
1514} ;
1615
1716let fetch : SinonStub ;
18- let transport : Transport ;
17+ let transport : Transports . BaseTransport ;
1918
2019describe ( 'FetchTransport' , ( ) => {
2120 beforeEach ( ( ) => {
2221 fetch = stub ( window , 'fetch' ) ;
23- transport = new FetchTransport ( { dsn : testDSN } ) ;
22+ transport = new Transports . FetchTransport ( { dsn : testDSN } ) ;
2423 } ) ;
2524
2625 afterEach ( ( ) => {
@@ -33,14 +32,13 @@ describe('FetchTransport', () => {
3332
3433 describe ( 'send()' , async ( ) => {
3534 it ( 'sends a request to Sentry servers' , async ( ) => {
36- const response = new Response ( '' , {
37- status : 200 ,
38- } ) ;
35+ const response = { status : 200 } ;
3936
4037 fetch . returns ( Promise . resolve ( response ) ) ;
4138
4239 return transport . send ( payload ) . then ( res => {
43- expect ( res . status ) . equal ( 200 ) ;
40+ expect ( res . code ) . equal ( 200 ) ;
41+ expect ( res . status ) . equal ( Status . Success ) ;
4442 expect ( fetch . calledOnce ) . equal ( true ) ;
4543 expect (
4644 fetch . calledWith ( transportUrl , {
@@ -54,9 +52,7 @@ describe('FetchTransport', () => {
5452 } ) ;
5553
5654 it ( 'rejects with non-200 status code' , async ( ) => {
57- const response = new Response ( '' , {
58- status : 403 ,
59- } ) ;
55+ const response = { status : 403 } ;
6056
6157 fetch . returns ( Promise . reject ( response ) ) ;
6258
0 commit comments