Skip to content

Commit 227c855

Browse files
committed
补充UT. review by chenmy
1 parent 3a38b23 commit 227c855

15 files changed

+1087
-17
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var FacilityAnalystStreamParameters = require('../../../src/common/iServer/FacilityAnalystStreamParameters').FacilityAnalystStreamParameters;
2+
3+
describe('FacilityAnalystStreamParameters', function () {
4+
it('constructor', function () {
5+
var options = {
6+
sourceNodeIDs: [84, 85],
7+
nodeID: 85,
8+
queryType: 0
9+
};
10+
var parameter = new FacilityAnalystStreamParameters(options);
11+
expect(parameter).not.toBeNull();
12+
expect(parameter.isUncertainDirectionValid).toBeFalsy();
13+
expect(parameter.nodeID).toEqual(85);
14+
expect(parameter.queryType).toEqual(0);
15+
expect(parameter.sourceNodeIDs.length).toEqual(2);
16+
parameter.destroy();
17+
expect(parameter.isUncertainDirectionValid).toBeNull();
18+
expect(parameter.edgeID).toBeNull();
19+
expect(parameter.nodeID).toBeNull();
20+
expect(parameter.weightName).toBeNull();
21+
expect(parameter.type).toBeNull();
22+
});
23+
});
24+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var LabelImageCell = require('../../../src/common/iServer/LabelImageCell').LabelImageCell;
2+
3+
describe('LabelImageCell', function () {
4+
it('constructor, destroy', function () {
5+
var labelImageCell = new LabelImageCell({pathField: "test"});
6+
expect(labelImageCell.CLASS_NAME).toEqual("SuperMap.LabelImageCell");
7+
expect(labelImageCell.pathField).toEqual("test");
8+
expect(labelImageCell.sizeFixed).toBeFalsy();
9+
expect(labelImageCell.type).toEqual("IMAGE");
10+
labelImageCell.destroy();
11+
expect(labelImageCell.height).toBeNull();
12+
expect(labelImageCell.pathField).toBeNull();
13+
expect(labelImageCell.rotation).toBeNull();
14+
expect(labelImageCell.width).toBeNull();
15+
expect(labelImageCell.sizeFixed).toBeNull();
16+
});
17+
});
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
var SummaryAttributesJobsParameter = require('../../../src/common/iServer/SummaryAttributesJobsParameter').SummaryAttributesJobsParameter;
2+
var OutputSetting = require('../../../src/common/iServer/OutputSetting').OutputSetting;
3+
4+
describe('SummaryAttributesJobsParameter', function () {
5+
it('constructor, destroy', function () {
6+
var options = {
7+
datasetName: 'testDatasetName',
8+
groupField: 'testField',
9+
attributeField: 'testAttrField',
10+
statisticModes: 'testType',
11+
};
12+
var datasourceConnectionInfo = new SuperMap.DatasourceConnectionInfo({
13+
alias:"dataSourceName",
14+
connect:"false",
15+
dataBase:"testDataBase",
16+
driver: "WMTS"
17+
});
18+
var parametersNull = new SummaryAttributesJobsParameter();
19+
expect(parametersNull).not.toBeNull();
20+
var parameters = new SummaryAttributesJobsParameter(options);
21+
expect(parameters).not.toBeNull();
22+
expect(parameters.datasetName).toEqual('testDatasetName');
23+
expect(parameters.groupField).toEqual('testField');
24+
expect(parameters.attributeField).toEqual('testAttrField');
25+
expect(parameters.statisticModes).toEqual('testType');
26+
expect(parameters.output).toEqual(null);
27+
parameters.output = new OutputSetting({
28+
type: SuperMap.OutputType.UDB,
29+
datasetName: 'testAnalystResult',
30+
datasourceInfo: datasourceConnectionInfo,
31+
outputPath: 'testpath'
32+
});
33+
parameters.destroy();
34+
expect(parameters.datasetName).toBeNull();
35+
expect(parameters.groupField).toBeNull();
36+
expect(parameters.attributeField).toBeNull();
37+
expect(parameters.statisticModes).toBeNull();
38+
expect(parameters.output).toBeNull();
39+
});
40+
41+
it('toObject', function () {
42+
var options = {
43+
datasetName: 'testDatasetName',
44+
groupField: 'testField',
45+
attributeField: 'testAttrField',
46+
statisticModes: 'testType',
47+
};
48+
var parameters = new SummaryAttributesJobsParameter(options);
49+
parameters.output = new OutputSetting({
50+
type: SuperMap.OutputType.UDB,
51+
datasetName: 'testAnalystResult',
52+
datasourceInfo: 'testInfo',
53+
outputPath: 'testpath'
54+
});
55+
var tempObj = new SummaryAttributesJobsParameter(options);
56+
new SuperMap.SummaryAttributesJobsParameter.toObject(parameters, tempObj);
57+
expect(tempObj.output.CLASS_NAME).toEqual("SuperMap.OutputSetting");
58+
expect(tempObj.output.datasetName).toEqual("testAnalystResult");
59+
expect(tempObj.output.type).toEqual("UDB");
60+
expect(tempObj.output.datasourceInfo).toEqual("testInfo");
61+
expect(tempObj.output.outputPath).toEqual("testpath");
62+
tempObj.destroy();
63+
parameters.destroy();
64+
});
65+
});
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
var ThemeDotDensity = require('../../../src/common/iServer/ThemeDotDensity').ThemeDotDensity;
2+
3+
describe('ThemeDotDensity', function () {
4+
it('constructor, destroy', function () {
5+
var options = {
6+
dotExpression: 'test',
7+
value: 1
8+
};
9+
var themeDotDensity = new ThemeDotDensity(options);
10+
expect(themeDotDensity.dotExpression).toEqual('test');
11+
expect(themeDotDensity.type).toEqual("DOTDENSITY");
12+
expect(themeDotDensity.value).toEqual(1);
13+
expect(themeDotDensity.style).not.toBeNull();
14+
themeDotDensity.destroy();
15+
expect(themeDotDensity.value).toBeNull();
16+
expect(themeDotDensity.style).toBeNull();
17+
expect(themeDotDensity.dotExpression).toBeNull();
18+
});
19+
20+
it('toServerJSONObject', function () {
21+
var options = {
22+
dotExpression: 'test',
23+
value: 1
24+
};
25+
var themeDotDensity = new ThemeDotDensity(options);
26+
var json = themeDotDensity.toServerJSONObject();
27+
expect(json).not.toBeNull();
28+
expect(json.dotExpression).toEqual('test');
29+
expect(json.type).toEqual("DOTDENSITY");
30+
expect(json.value).toEqual(1);
31+
expect(json.style).not.toBeNull();
32+
themeDotDensity.destroy();
33+
});
34+
35+
it('fromObj', function () {
36+
var options = {
37+
dotExpression: 'test',
38+
value: 1
39+
};
40+
var themeDotDensity = new ThemeDotDensity(options);
41+
var newObject = new ThemeDotDensity.fromObj(themeDotDensity);
42+
expect(newObject).not.toBeNull();
43+
expect(newObject.dotExpression).toEqual('test');
44+
expect(newObject.type).toEqual("DOTDENSITY");
45+
expect(newObject.value).toEqual(1);
46+
expect(newObject.style).not.toBeNull();
47+
var newObject1 = new ThemeDotDensity.fromObj();
48+
expect(newObject1).not.toBeNull();
49+
themeDotDensity.destroy();
50+
});
51+
52+
});
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
var ThemeGridRange = require('../../../src/common/iServer/ThemeGridRange').ThemeGridRange;
2+
var ThemeGridRangeItem = require('../../../src/common/iServer/ThemeGridRangeItem').ThemeGridRangeItem;
3+
4+
describe('ThemeGridRange', function () {
5+
it('constructor, destroy', function () {
6+
var options = {
7+
items: [new ThemeGridRangeItem({caption: "test1"}),
8+
new ThemeGridRangeItem({caption: "test2"})],
9+
};
10+
var themeGridRange = new ThemeGridRange(options);
11+
expect(themeGridRange).not.toBeNull();
12+
expect(themeGridRange.reverseColor).not.toBeNull();
13+
expect(themeGridRange.colorGradientType).toEqual("YELLOWRED");
14+
expect(themeGridRange.items.length).toEqual(2);
15+
expect(themeGridRange.items[0].caption).toEqual("test1");
16+
expect(themeGridRange.items[1].caption).toEqual("test2");
17+
expect(themeGridRange.rangeMode).toEqual("EQUALINTERVAL");
18+
expect(themeGridRange.type).toEqual("GRIDRANGE");
19+
var json = themeGridRange.items[0].toServerJSONObject();
20+
expect(json).not.toBeNull();
21+
expect(json.caption).toEqual("test1");
22+
expect(json.visible).toBeTruthy();
23+
var newItems1 = new ThemeGridRangeItem.fromObj(themeGridRange.items[0]);
24+
expect(newItems1.caption).toEqual("test1");
25+
expect(newItems1.color.red).toEqual(255);
26+
var newItems2 = new ThemeGridRangeItem.fromObj();
27+
expect(newItems2).not.toBeNull();
28+
themeGridRange.destroy();
29+
expect(themeGridRange.items).toBeNull();
30+
expect(themeGridRange.reverseColor).toBeNull();
31+
expect(themeGridRange.rangeMode).toBeNull();
32+
expect(themeGridRange.rangeParameter).toBeNull();
33+
expect(themeGridRange.colorGradientType).toBeNull();
34+
});
35+
36+
it('fromObj',function () {
37+
var options = {
38+
items: [new ThemeGridRangeItem({caption: "test1"})],
39+
};
40+
var themeGridRange = new ThemeGridRange(options);
41+
var newThemeGridRange = new ThemeGridRange.fromObj(themeGridRange);
42+
expect(newThemeGridRange).not.toBeNull();
43+
expect(newThemeGridRange.items[0].caption).toEqual("test1");
44+
expect(newThemeGridRange.colorGradientType).toEqual("YELLOWRED");
45+
expect(newThemeGridRange.rangeMode).toEqual("EQUALINTERVAL");
46+
expect(newThemeGridRange.type).toEqual("GRIDRANGE");
47+
var newThemeGridRange1 = new ThemeGridRange.fromObj();
48+
expect(newThemeGridRange1).not.toBeNull();
49+
newThemeGridRange.destroy();
50+
});
51+
});
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
var ThemeGridUnique = require('../../../src/common/iServer/ThemeGridUnique').ThemeGridUnique;
2+
var ThemeGridUniqueItem = require('../../../src/common/iServer/ThemeGridUniqueItem').ThemeGridUniqueItem;
3+
4+
describe('ThemeGridUnique',function () {
5+
6+
it('constructor, destroy',function () {
7+
var themeGrid = new ThemeGridUnique({
8+
items:[
9+
new ThemeGridUniqueItem({caption:"test1"}),
10+
new ThemeGridUniqueItem({caption:"test2"}),
11+
new ThemeGridUniqueItem({caption:"test3"}),
12+
]
13+
});
14+
expect(themeGrid).not.toBeNull();
15+
expect(themeGrid.defaultcolor).not.toBeNull();
16+
expect(themeGrid.defaultcolor.red).toEqual(255);
17+
expect(themeGrid.items.length).toEqual(3);
18+
expect(themeGrid.items[0].caption).toEqual("test1");
19+
expect(themeGrid.items[1].caption).toEqual("test2");
20+
expect(themeGrid.items[2].caption).toEqual("test3");
21+
expect(themeGrid.type).toEqual("GRIDUNIQUE");
22+
themeGrid.destroy();
23+
expect(themeGrid.defaultcolor).toBeNull();
24+
expect(themeGrid.items).toBeNull();
25+
expect(themeGrid.type).toBeNull();
26+
expect(themeGrid.memoryData).toBeNull();
27+
});
28+
it('toServerJSONObject',function () {
29+
var themeGrid = new ThemeGridUnique({
30+
items:[
31+
new ThemeGridUniqueItem({caption:"test1"}),
32+
new ThemeGridUniqueItem({caption:"test2"})
33+
]
34+
});
35+
var obj = themeGrid.toServerJSONObject();
36+
expect(obj).not.toBeNull();
37+
expect(obj.defaultcolor).not.toBeNull();
38+
expect(obj.defaultcolor.red).toEqual(255);
39+
expect(obj.items.length).toEqual(2);
40+
expect(obj.items[0].caption).toEqual("test1");
41+
expect(obj.items[1].caption).toEqual("test2");
42+
expect(obj.type).toEqual("GRIDUNIQUE");
43+
themeGrid.destroy();
44+
});
45+
46+
it('fromObj',function () {
47+
var themeGrid = new ThemeGridUnique({
48+
items:[
49+
new ThemeGridUniqueItem({caption:"test1"}),
50+
new ThemeGridUniqueItem({caption:"test2"})
51+
]
52+
});
53+
var newThemeGrid = new ThemeGridUnique.fromObj(themeGrid);
54+
expect(newThemeGrid).not.toBeNull();
55+
expect(newThemeGrid.defaultcolor).not.toBeNull();
56+
expect(newThemeGrid.defaultcolor.red).toEqual(255);
57+
expect(newThemeGrid.items.length).toEqual(2);
58+
expect(newThemeGrid.items[0].caption).toEqual("test1");
59+
expect(newThemeGrid.items[1].caption).toEqual("test2");
60+
expect(newThemeGrid.type).toEqual("GRIDUNIQUE");
61+
themeGrid.destroy();
62+
newThemeGrid.destroy();
63+
});
64+
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
var ThemeLabelUniqueItem = require('../../../src/common/iServer/ThemeLabelUniqueItem').ThemeLabelUniqueItem;
2+
3+
describe('ThemeLabelUniqueItem',function () {
4+
var originalTimeout;
5+
beforeEach(function () {
6+
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
7+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
8+
});
9+
afterEach(function () {
10+
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
11+
});
12+
13+
it('constructor, destroy',function () {
14+
var themeLabel = new ThemeLabelUniqueItem({caption:"testCaption"});
15+
expect(themeLabel).not.toBeNull();
16+
expect(themeLabel.caption).toEqual("testCaption");
17+
expect(themeLabel.offsetX).toEqual(0);
18+
expect(themeLabel.offsetY).toEqual(0);
19+
expect(themeLabel.style).not.toBeNull();
20+
expect(themeLabel.style.CLASS_NAME).toEqual("SuperMap.ServerTextStyle");
21+
themeLabel.destroy();
22+
expect(themeLabel.caption).toBeNull();
23+
expect(themeLabel.offsetX).toBeNull();
24+
expect(themeLabel.offsetY).toBeNull();
25+
expect(themeLabel.style).toBeNull();
26+
});
27+
it('fromObj',function () {
28+
var themeLabel = new ThemeLabelUniqueItem({caption:"testCaption"});
29+
var newThemeLabel = new ThemeLabelUniqueItem.fromObj(themeLabel);
30+
expect(newThemeLabel).not.toBeNull();
31+
expect(newThemeLabel.caption).toEqual("testCaption");
32+
var newThemeLabel2 = new ThemeLabelUniqueItem.fromObj();
33+
expect(newThemeLabel2).not.toBeNull();
34+
});
35+
36+
});
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
var ThemeRange = require('../../../src/common/iServer/ThemeRange').ThemeRange;
2+
var ThemeRangeItem = require('../../../src/common/iServer/ThemeRangeItem').ThemeRangeItem;
3+
4+
describe('ThemeRange', function () {
5+
it('constructor, destroy', function () {
6+
var options = {
7+
items: [new ThemeRangeItem({caption: 'test1'})],
8+
};
9+
var themeRange = new ThemeRange(options);
10+
expect(themeRange).not.toBeNull();
11+
expect(themeRange.colorGradientType).toEqual("YELLOWRED");
12+
expect(themeRange.precision).toEqual("1.0E-12");
13+
expect(themeRange.items[0].caption).toEqual('test1');
14+
expect(themeRange.rangeMode).toEqual("EQUALINTERVAL");
15+
expect(themeRange.type).toEqual("RANGE");
16+
var json = themeRange.items[0].toServerJSONObject();
17+
expect(json).not.toBeNull();
18+
expect(json.caption).toEqual('test1');
19+
expect(json.style).not.toBeNull();
20+
var newObject = new ThemeRangeItem.fromObj(themeRange.items[0]);
21+
expect(newObject).not.toBeNull();
22+
expect(newObject.caption).toEqual('test1');
23+
expect(newObject.style).not.toBeNull();
24+
var newObject1 = new ThemeRangeItem.fromObj();
25+
expect(newObject1).not.toBeNull();
26+
themeRange.destroy();
27+
expect(themeRange.items).toBeNull();
28+
expect(themeRange.rangeExpression).toBeNull();
29+
expect(themeRange.rangeMode).toBeNull();
30+
expect(themeRange.rangeParameter).toBeNull();
31+
expect(themeRange.colorGradientType).toBeNull();
32+
});
33+
34+
it('fromObj', function () {
35+
var options = {
36+
items: [new ThemeRangeItem({caption: 'test1'})],
37+
};
38+
var themeRange = new ThemeRange(options);
39+
var newObject = new ThemeRange.fromObj(themeRange);
40+
expect(newObject).not.toBeNull();
41+
expect(newObject.colorGradientType).toEqual("YELLOWRED");
42+
expect(newObject.precision).toEqual("1.0E-12");
43+
expect(newObject.items[0].caption).toEqual('test1');
44+
expect(newObject.rangeMode).toEqual("EQUALINTERVAL");
45+
expect(newObject.type).toEqual("RANGE");
46+
var newObject1 = new ThemeRange.fromObj();
47+
expect(newObject1).not.toBeNull();
48+
themeRange.destroy();
49+
});
50+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var OnlineQueryDatasParameter = require('../../../src/common/online/OnlineQueryDatasParameter').OnlineQueryDatasParameter;
2+
3+
describe('OnlineQueryDatasParameter, toJSON', function () {
4+
it('constructor', function () {
5+
var parameter = new OnlineQueryDatasParameter({fileName:"testFileName"});
6+
expect(parameter).not.toBeNull();
7+
expect(parameter.CLASS_NAME).toEqual("SuperMap.OnlineQueryDatasParameter");
8+
var json = parameter.toJSON();
9+
expect(json).not.toBeNull();
10+
expect(json.fileName).toEqual("testFileName");
11+
});
12+
});

0 commit comments

Comments
 (0)