Skip to content

Commit c4dabff

Browse files
git
1 parent b15ec0e commit c4dabff

11 files changed

Lines changed: 33 additions & 45 deletions

File tree

‎test/common/iServer/KnowledgeGraphServiceSpec.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ describe('KnowledgeGraphService', () => {
3939
it('findShortestPath', (done) => {
4040
var knowledgeGraphService = new KnowledgeGraphService(knowledgegraphURL);
4141
spyOn(FetchRequest, 'get').and.callFake((testUrl, params, options) => {
42-
expect(testUrl).toBe(knowledgegraphURL + '/shortestPath.json?startid=38756&endid=38757');
42+
expect(testUrl).toBe(knowledgegraphURL + '/shortestPath.json?startID=38756&endID=38757');
4343
expect(options).not.toBeNull();
44-
return Promise.resolve(new Response(getShortestPathData));
44+
return Promise.resolve(new Response(findShortestPathData));
4545
});
46-
knowledgeGraphService.findShortestPath({startid:38756, endid:38757}, (res) => {
46+
knowledgeGraphService.findShortestPath({startID:38756, endID:38757}, (res) => {
4747
try {
4848
expect(knowledgeGraphService).not.toBeNull();
4949
expect(res).not.toBeNull();
@@ -55,7 +55,6 @@ describe('KnowledgeGraphService', () => {
5555
done();
5656
} catch (exception) {
5757
console.log("'findShortestPath'案例失败:" + exception.name + ':' + exception.message);
58-
knowledgeGraphService.destroy();
5958
expect(false).toBeTruthy();
6059
done();
6160
}

‎test/common/overlay/KnowledgeGraphSpec.js‎

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -787,12 +787,13 @@ describe('KnowledgeGraph', () => {
787787
var graph = new KnowledgeGraph({ nodeLabelMaxWidth: 100 });
788788
spyOn(graph.graph, 'setItemState');
789789
spyOn(graph.graph, 'clearItemStates');
790-
graph.graph.emit('node:mouseenter', { a: 'heloooo' });
790+
791+
graph.graph.emit('node:mouseenter', { item: { test: 'heloooo' } });
791792
expect(graph.graph.setItemState).toHaveBeenCalled();
792793
graph.graph.emit('node:mouseleave');
793794
expect(graph.graph.clearItemStates).toHaveBeenCalled();
794795

795-
graph.graph.emit('edge:mouseenter');
796+
graph.graph.emit('edge:mouseenter', { item: { test: 'heloooo' } });
796797
expect(graph.graph.setItemState).toHaveBeenCalled();
797798
graph.graph.emit('edge:mouseleave');
798799
expect(graph.graph.clearItemStates).toHaveBeenCalled();
@@ -801,6 +802,9 @@ describe('KnowledgeGraph', () => {
801802

802803
it('highlight', (done) => {
803804
var graph = new KnowledgeGraph({ nodeLabelMaxWidth: 100 });
805+
spyOn(graph.graph, 'setItemState');
806+
spyOn(graph.graph, 'updateItem');
807+
804808
var highlightStateStyles = {
805809
nodeStateStyles: {
806810
lineWidth: 3,
@@ -816,42 +820,35 @@ describe('KnowledgeGraph', () => {
816820
}
817821
}
818822
};
819-
graph.highlight({ nodeIDs: [1], edgeIDs: [2], ...highlightStateStyles });
820-
graph.findById = () => true;
821-
graph.find = () => true;
822823

823-
spyOn(graph.graph, 'setItemState');
824-
spyOn(graph.graph, 'updateItem');
825-
826-
expect(graph.graph.setItemState).toHaveBeenCalled();
827-
expect(graph.graph.updateItem).toHaveBeenCalled();
828-
829-
graph.highlight({ nodeIDs: [3], edgeIDs: [4] });
830824
graph.findById = () => false;
831825
graph.find = () => false;
826+
graph.highlight({ nodeIDs: [3], edgeIDs: [4] });
832827
expect(graph.graph.setItemState).not.toHaveBeenCalled();
833828

829+
graph.findById = () => true;
830+
graph.find = () => true;
831+
graph.highlight({ nodeIDs: [1], edgeIDs: [2], ...highlightStateStyles });
832+
833+
expect(graph.graph.setItemState).toHaveBeenCalled();
834+
expect(graph.graph.updateItem).toHaveBeenCalled();
834835
done();
835836
});
836837

837838
it('clearHighlight', (done) => {
838839
var graph = new KnowledgeGraph({ nodeLabelMaxWidth: 100 });
839840
spyOn(graph.graph, 'clearItemStates');
840841

841-
graph.clearHighlight({ nodeIDs: [1], edgeIDs: [2] });
842-
graph.findById = () => true;
843-
graph.find = () => true;
844-
expect(graph.graph.clearItemStates).toHaveBeenCalled();
845-
846-
graph.clearHighlight({ nodeIDs: [3], edgeIDs: [4] });
847842
graph.findById = () => false;
848843
graph.find = () => false;
844+
graph.clearHighlight({ nodeIDs: [3], edgeIDs: [4] });
849845
expect(graph.graph.clearItemStates).not.toHaveBeenCalled();
850846

851-
graph.getNodes = () => [true];
852-
graph.getEdges = () => [true];
847+
graph.findById = () => true;
848+
graph.find = () => true;
849+
graph.clearHighlight({ nodeIDs: [1], edgeIDs: [2] });
850+
expect(graph.graph.clearItemStates).toHaveBeenCalled();
853851
graph.clearHighlight();
854-
855852
expect(graph.graph.clearItemStates).toHaveBeenCalled();
856853
done();
857854
});

‎test/leaflet/overlay/GraphMapSpec.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('GraphMap leaflet', () => {
5555
if (testUrl.includes('/shortestPath.json')) {
5656
expect(testUrl).toBe(knowledgegraphURL + '/shortestPath.json?startid=38756&endid=38757');
5757
expect(options).not.toBeNull();
58-
return Promise.resolve(new Response(getShortestPathData));
58+
return Promise.resolve(new Response(findShortestPathData));
5959
}
6060
});
6161
var graphMap = new GraphMap(knowledgegraphmapURL, { config: { center: [0, 0] } });

‎test/leaflet/services/KnowledgeGraphServiceSpec.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('leaflet_KnowledgeGraphService', () => {
3737
spyOn(FetchRequest, 'get').and.callFake((testUrl, params, options) => {
3838
expect(testUrl).toBe(knowledgegraphURL + '/shortestPath.json?startID=38756&endID=38757');
3939
expect(options).not.toBeNull();
40-
return Promise.resolve(new Response(getShortestPathData));
40+
return Promise.resolve(new Response(findShortestPathData));
4141
});
4242
knowledgeGraphService.findShortestPath({ startID: 38756, endID: 38757 }, (res) => {
4343
try {
@@ -47,11 +47,9 @@ describe('leaflet_KnowledgeGraphService', () => {
4747
expect(res.result).not.toBeNull();
4848
expect(res.result.nodeIDs).toEqual([40229, 40237, 64058]);
4949
expect(res.result.edgeIDs).toEqual([69575, 66619]);
50-
knowledgeGraphService.destroy();
5150
done();
5251
} catch (exception) {
5352
console.log("'findShortestPath'案例失败:" + exception.name + ':' + exception.message);
54-
knowledgeGraphService.destroy();
5553
expect(false).toBeTruthy();
5654
done();
5755
}

‎test/mapboxgl/overlay/GraphMapSpec.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('GraphMap mapboxgl', () => {
5555
if (testUrl.includes('/shortestPath.json')) {
5656
expect(testUrl).toBe(knowledgegraphURL + '/shortestPath.json?startid=38756&endid=38757');
5757
expect(options).not.toBeNull();
58-
return Promise.resolve(new Response(getShortestPathData));
58+
return Promise.resolve(new Response(findShortestPathData));
5959
}
6060
});
6161
var graphMap = new GraphMap(knowledgegraphmapURL, { config: { center: [0, 0] } });

‎test/mapboxgl/services/KnowledgeGraphServiceSpec.js‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,21 @@ describe('mapboxgl_KnowledgeGraphService', () => {
3535
it('findShortestPath', (done) => {
3636
var knowledgeGraphService = new KnowledgeGraphService(knowledgegraphURL);
3737
spyOn(FetchRequest, 'get').and.callFake((testUrl, params, options) => {
38-
expect(testUrl).toBe(knowledgegraphURL + '/shortestPath.json?startid=38756&endid=38757');
38+
expect(testUrl).toBe(knowledgegraphURL + '/shortestPath.json?startID=38756&endID=38757');
3939
expect(options).not.toBeNull();
40-
return Promise.resolve(new Response(getShortestPathData));
40+
return Promise.resolve(new Response(findShortestPathData));
4141
});
42-
knowledgeGraphService.findShortestPath({ startid: 38756, endid: 38757 }, (res) => {
42+
knowledgeGraphService.findShortestPath({ startID: 38756, endID: 38757 }, (res) => {
4343
try {
4444
expect(knowledgeGraphService).not.toBeNull();
4545
expect(res).not.toBeNull();
4646
expect(res.type).toBe('processCompleted');
4747
expect(res.result).not.toBeNull();
4848
expect(res.result.nodeIDs).toEqual([40229, 40237, 64058]);
4949
expect(res.result.edgeIDs).toEqual([69575, 66619]);
50-
knowledgeGraphService.destroy();
5150
done();
5251
} catch (exception) {
5352
console.log("'findShortestPath'案例失败:" + exception.name + ':' + exception.message);
54-
knowledgeGraphService.destroy();
5553
expect(false).toBeTruthy();
5654
done();
5755
}

‎test/maplibregl/overlay/GraphMapSpec.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('GraphMap maplibregl', () => {
5454
if (testUrl.includes('/shortestPath.json')) {
5555
expect(testUrl).toBe(knowledgegraphURL + '/shortestPath.json?startID=38756&endID=38757');
5656
expect(options).not.toBeNull();
57-
return Promise.resolve(new Response(getShortestPathData));
57+
return Promise.resolve(new Response(findShortestPathData));
5858
}
5959
});
6060
var graphMap = new GraphMap(knowledgegraphmapURL, { config: { center: [0, 0] } });

‎test/maplibregl/services/KnowledgeGraphServiceSpec.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('maplibregl_KnowledgeGraphService', () => {
3737
spyOn(FetchRequest, 'get').and.callFake((testUrl, params, options) => {
3838
expect(testUrl).toBe(knowledgegraphURL + '/shortestPath.json?startID=38756&endID=38757');
3939
expect(options).not.toBeNull();
40-
return Promise.resolve(new Response(getShortestPathData));
40+
return Promise.resolve(new Response(findShortestPathData));
4141
});
4242
knowledgeGraphService.findShortestPath({ startID: 38756, endID: 38757 }, (res) => {
4343
try {
@@ -47,11 +47,9 @@ describe('maplibregl_KnowledgeGraphService', () => {
4747
expect(res.result).not.toBeNull();
4848
expect(res.result.nodeIDs).toEqual([40229, 40237, 64058]);
4949
expect(res.result.edgeIDs).toEqual([69575, 66619]);
50-
knowledgeGraphService.destroy();
5150
done();
5251
} catch (exception) {
5352
console.log("'findShortestPath'案例失败:" + exception.name + ':' + exception.message);
54-
knowledgeGraphService.destroy();
5553
expect(false).toBeTruthy();
5654
done();
5755
}

‎test/openlayers/overlay/GraphMapSpec.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('GraphMap openlayers', () => {
5454
if (testUrl.includes('/shortestPath.json')) {
5555
expect(testUrl).toBe(knowledgegraphURL + '/shortestPath.json?startID=38756&endID=38757');
5656
expect(options).not.toBeNull();
57-
return Promise.resolve(new Response(getShortestPathData));
57+
return Promise.resolve(new Response(findShortestPathData));
5858
}
5959
});
6060
var graphMap = new GraphMap(knowledgegraphmapURL, { config: { center: [0, 0] } });

‎test/openlayers/services/KnowledgeGraphServiceSpec.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('openlayers_KnowledgeGraphService', () => {
3737
spyOn(FetchRequest, 'get').and.callFake((testUrl, params, options) => {
3838
expect(testUrl).toBe(knowledgegraphURL + '/shortestPath.json?startID=38756&endID=38757');
3939
expect(options).not.toBeNull();
40-
return Promise.resolve(new Response(getShortestPathData));
40+
return Promise.resolve(new Response(findShortestPathData));
4141
});
4242
knowledgeGraphService.findShortestPath({ startID: 38756, endID: 38757 }, (res) => {
4343
try {
@@ -47,11 +47,9 @@ describe('openlayers_KnowledgeGraphService', () => {
4747
expect(res.result).not.toBeNull();
4848
expect(res.result.nodeIDs).toEqual([40229, 40237, 64058]);
4949
expect(res.result.edgeIDs).toEqual([69575, 66619]);
50-
knowledgeGraphService.destroy();
5150
done();
5251
} catch (exception) {
5352
console.log("'findShortestPath'案例失败:" + exception.name + ':' + exception.message);
54-
knowledgeGraphService.destroy();
5553
expect(false).toBeTruthy();
5654
done();
5755
}

0 commit comments

Comments
 (0)