Skip to content

Commit e3347d9

Browse files
committed
新增FetchRequest UT review by songym
1 parent 872ecce commit e3347d9

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/common/util/FetchRequest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export var FetchRequest = SuperMap.FetchRequest = {
129129
url: url += "&_method=PUT",
130130
data: params
131131
};
132-
return SuperMap.Util.RequestJSONPPromise.DELETE(config);
132+
return SuperMap.Util.RequestJSONPPromise.PUT(config);
133133

134134
}
135135
return this._fetch(url, params, options, 'PUT');

test/common/util/FetchRequestSpec.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { FetchRequest, isCORS, setCORS } from '../../../src/common//util/FetchRequest';
2+
3+
describe('FetchRequest', () => {
4+
5+
it('RequestJSONPPromise', () => {
6+
var url = "http://test.supermap.io/examples/leaflet/editor.html#addressMatchService";
7+
var params;
8+
var options;
9+
spyOn(SuperMap.Util.RequestJSONPPromise, 'issue').and.callThrough();
10+
setCORS(false);
11+
FetchRequest.get(url, params, options);
12+
expect(SuperMap.Util.RequestJSONPPromise.issue).toHaveBeenCalled();
13+
var paramsde = {
14+
"completeLineSymbolDisplayed": false,
15+
"visible": true,
16+
};
17+
SuperMap.Util.RequestJSONPPromise.limitLength = 5;
18+
var deleteUri = "http://test/GUID=PCdd8b1ab00896b3a7a&app=ydrive&cl=desktop?leftBottom%22%20:%20%7B%22x%22:NaN,%22y%22:NaN%7D,%22rightTo"
19+
FetchRequest.delete(deleteUri, paramsde, options);
20+
expect(SuperMap.Util.RequestJSONPPromise.issue.calls.count()).toBe(2);
21+
22+
FetchRequest.post(deleteUri, paramsde, options);
23+
expect(SuperMap.Util.RequestJSONPPromise.issue.calls.count()).toBe(3);
24+
25+
SuperMap.Util.RequestJSONPPromise.limitLength = 180;
26+
spyOn(FetchRequest, '_fetchJsonp').and.callFake(() => {
27+
});
28+
FetchRequest.put(deleteUri, paramsde, options);
29+
expect(SuperMap.Util.RequestJSONPPromise.issue.calls.count()).toBe(4);
30+
});
31+
32+
33+
})

test/test-main-common.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,5 @@ import './common/iPortal/iPortalServicesQueryParamSpec.js';
163163

164164
/**common -- thirdparty**/
165165
import './common/thirdparty/elasticsearch/ElasticSearchSpec.js';
166+
167+
import './common/util/FetchRequestSpec';

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy