@@ -63,37 +63,7 @@ describe('pretender invoking by fetch', function(config) {
6363 return wait ;
6464 } ) ;
6565
66-
67- // TODO: Pretender doesn't work with abortable fetch
68- // src in fake_xml_http_request.js
69- // ```
70- // abort: function abort() {
71- // this.aborted = true;
72- // this.responseText = null;
73- // this.errorFlag = true;
74- // this.requestHeaders = {};
75-
76- // if (this.readyState > FakeXMLHttpRequest.UNSENT && this.sendFlag) {
77- // this._readyStateChange(FakeXMLHttpRequest.DONE);
78- // this.sendFlag = false;
79- // }
80-
81- // this.readyState = FakeXMLHttpRequest.UNSENT;
82-
83- // this.dispatchEvent(new _Event("abort", false, false, this));
84- // if (typeof this.onerror === "function") {
85- // this.onerror();
86- // }
87- // }
88- // ```
89- // For `fake_xml_http_request` impl, the request is resolved once its state
90- // is changed to `DONE` so the `reject` is not cathed.
91- // So the senario happens in pretender is:
92- // 1. state chagne to `DONE`, trigger resolve request
93- // 2. abort, trigger reject
94- // 3. xhr.onerror, trigger reject
95- // The first resolve wins, error thus not rejected but an empty request is resolved.
96- it ( 'has NO Abortable fetch' , function ( assert ) {
66+ it ( 'has Abortable fetch' , function ( assert ) {
9767 assert . expect ( 1 ) ;
9868 this . pretender . get (
9969 '/downloads' ,
@@ -110,8 +80,8 @@ describe('pretender invoking by fetch', function(config) {
11080 } , 10 ) ;
11181
11282 return fetch ( '/downloads' , { signal : signal } )
113- . then ( function ( data ) {
114- assert . ok ( data , 'AbortError was not rejected ' ) ;
83+ . catch ( function ( err ) {
84+ assert . equal ( err . name , 'AbortError' ) ;
11585 } ) ;
11686 } ) ;
11787} ) ;
0 commit comments