Skip to content

Commit 816ac2e

Browse files
spy部分UT;添加断言;补充UT案例
1 parent 0149ed3 commit 816ac2e

File tree

5 files changed

+197
-159
lines changed

5 files changed

+197
-159
lines changed

test/common/iServer/BurstPipelineAnalystServiceSpec.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function analyzeFailed(serviceFailedEventArgs) {
1919
function analyzeCompleted(analyseEventArgs) {
2020
serviceCompletedEventArgsSystem = analyseEventArgs;
2121
}
22-
2322
describe('BurstPipelineAnalystService', function () {
2423
var originalTimeout;
2524
var FetchRequest = SuperMap.FetchRequest;
@@ -42,6 +41,8 @@ describe('BurstPipelineAnalystService', function () {
4241
expect(burstPipelineAnalystParams.edgeID).toBeNull();
4342
expect(burstPipelineAnalystParams.nodeID).toBeNull();
4443
expect(burstPipelineAnalystParams.isUncertainDirectionValid).toBeFalsy();
44+
burstPipelineAnalystService.destroy();
45+
burstPipelineAnalystParams.destroy();
4546
});
4647

4748
it('constructor, destroy', function () {
@@ -64,7 +65,7 @@ describe('BurstPipelineAnalystService', function () {
6465
expect(burstPipelineAnalystParams.isUncertainDirectionValid).toBeFalsy();
6566
});
6667

67-
//参数不存在, 直接返回
68+
//参数不存在, 直接返回, 此处不应该直接返回,应该报错?待与开发协商
6869
it('processAsync_noParams', function (done) {
6970
var burstPipelineAnalystService = initBurstPipelineAnalystService();
7071
burstPipelineAnalystService.processAsync();
@@ -85,9 +86,16 @@ describe('BurstPipelineAnalystService', function () {
8586
nodeID: null,
8687
isUncertainDirectionValid: true
8788
});
88-
spyOn(FetchRequest, 'commit').and.callFake(function () {
89-
var burstPipelineEscapedJson = "{\"normalNodes\":[],\"edges\":[1,2,3,4,5,6,7,8,9],\"criticalNodes\":[2]}";
90-
return Promise.resolve(new Response(burstPipelineEscapedJson));
89+
spyOn(FetchRequest, 'commit').and.callFake(function (method, testUrl, params, options) {
90+
expect(method).toBe('GET');
91+
expect(testUrl).toBe(url + "/burstAnalyse.json?");
92+
expect(params.edgeID).toEqual(3434);
93+
expect(params.isUncertainDirectionValid).toBe(true);
94+
expect(params.sourceNodeIDs[0]).toEqual(1);
95+
expect(params.sourceNodeIDs[1]).toEqual(2);
96+
expect(options).not.toBeNull();
97+
var escapedJson = "{\"normalNodes\":[],\"edges\":[1,2,3,4,5,6,7,8,9],\"criticalNodes\":[2]}";
98+
return Promise.resolve(new Response(escapedJson));
9199
});
92100
burstPipelineAnalystService.processAsync(burstPipelineAnalystParams);
93101
setTimeout(function () {

0 commit comments

Comments
 (0)