|
| 1 | +require('../../../src/common/overlay/Graph'); |
| 2 | + |
| 3 | +describe('common_Graph', 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 | + |
| 14 | + it('constructor_test', function () { |
| 15 | + var geometry = new SuperMap.Geometry.Point(-115, 10); |
| 16 | + var attributes = { |
| 17 | + 'SMID': 1, |
| 18 | + 'CAPITAL_CH': "巴西利亚" |
| 19 | + }; |
| 20 | + var style = { |
| 21 | + strokeColor: "#339933", |
| 22 | + strokeOpacity: 1, |
| 23 | + strokeWidth: 3, |
| 24 | + pointRadius: 6 |
| 25 | + }; |
| 26 | + var data = new SuperMap.Feature.Vector(geometry, attributes, style); |
| 27 | + var layer = "continent_T@World"; |
| 28 | + var fields = ["SMID", "CAPITAL_CH"];// data 中的参与此图表生成的字段名称 |
| 29 | + var setting = { |
| 30 | + width: 500, |
| 31 | + height: 300, |
| 32 | + codomain: [0, 300], |
| 33 | + XOffset: 10, |
| 34 | + YOffset: 10, |
| 35 | + dataViewBoxParameter: [5, 5, 5, 5], |
| 36 | + decimalNumber: 0 |
| 37 | + }; |
| 38 | + //专题要素地理位置。默认为 data 指代的地理要素 Bounds 中心。 |
| 39 | + var lonlat = new SuperMap.LonLat(0, -20); |
| 40 | + var point = new SuperMap.Feature.ShapeParameters.Point; |
| 41 | + var options = { |
| 42 | + shapeFactory: point, |
| 43 | + shapeParameters: { |
| 44 | + clickable: true, |
| 45 | + hoverable: true |
| 46 | + }, |
| 47 | + RelativeCoordinate: true, |
| 48 | + origonPoint: [0, 0], |
| 49 | + chartBox: [0, -300, 500, 0], |
| 50 | + width: 500, |
| 51 | + height: 300, |
| 52 | + XOffset: 10, |
| 53 | + YOffset: 10, |
| 54 | + DVBParameter: [5, 5, 5, 5], |
| 55 | + dataViewBox: [400, 250], |
| 56 | + DVBCodomain: [0, 300], |
| 57 | + DVBOrigonPoint: [50, -25], |
| 58 | + DVBWidth: 400, |
| 59 | + DVBHeight: 250, |
| 60 | + origonPointOffset: [0, 0], |
| 61 | + fields: ["SMID", "CAPITAL_CH"], |
| 62 | + }; |
| 63 | + |
| 64 | + var graph = new SuperMap.Feature.Theme.Graph(data, layer, fields, setting, options, lonlat); |
| 65 | + expect(graph).not.toBeNull(); |
| 66 | + expect(graph.RelativeCoordinate).toBe(false); |
| 67 | + expect(graph.fields).not.toBeNull(); |
| 68 | + expect(graph.fields.length).toEqual(2); |
| 69 | + expect(graph.fields[0]).toEqual("SMID"); |
| 70 | + expect(graph.fields[1]).toEqual("CAPITAL_CH"); |
| 71 | + expect(graph.lonlat.shapeFactory.CLASS_NAME).toEqual("SuperMap.Feature.ShapeParameters.Point"); |
| 72 | + expect(graph.lonlat.shapeParameters.clickable).toBe(true); |
| 73 | + expect(graph.lonlat.shapeParameters.hoverable).toBe(true); |
| 74 | + expect(graph.lonlat.XOffset).toEqual(10); |
| 75 | + expect(graph.lonlat.RelativeCoordinate).toBe(true); |
| 76 | + expect(graph.setting).not.toBeNull(); |
| 77 | + expect(graph.lonlat.DVBHeight).toEqual(options.DVBHeight); |
| 78 | + expect(graph.lonlat.DVBWidth).toEqual(options.DVBWidth); |
| 79 | + expect(graph.lonlat.DVBCodomain[0]).toEqual(0); |
| 80 | + expect(graph.lonlat.DVBCodomain[1]).toEqual(300); |
| 81 | + expect(graph.lonlat.DVBOrigonPoint[0]).toEqual(50); |
| 82 | + expect(graph.lonlat.DVBOrigonPoint[1]).toEqual(-25); |
| 83 | + for (var i = 0; i < graph.lonlat.DVBParameter.length; i++) { |
| 84 | + expect(graph.lonlat.DVBParameter[i]).toEqual(5); |
| 85 | + } |
| 86 | + for (var j = 0; i < graph.setting.dataViewBoxParameter.length; j++) { |
| 87 | + expect(graph.setting.dataViewBoxParameter[j]).toEqual(5); |
| 88 | + } |
| 89 | + expect(graph.setting.decimalNumber).toEqual(setting.decimalNumber); |
| 90 | + |
| 91 | + graph.destroy(); |
| 92 | + expect(graph.width).toBeNull(); |
| 93 | + expect(graph.height).toBeNull(); |
| 94 | + expect(graph.setting).toBeNull(); |
| 95 | + expect(graph.shapeFactory).toBeNull(); |
| 96 | + expect(graph.shapeParameters).toBeNull(); |
| 97 | + expect(graph.chartBox).toBeNull(); |
| 98 | + expect(graph.fields).toBeNull(); |
| 99 | + expect(graph.dataValues).toBeNull(); |
| 100 | + }); |
| 101 | +}); |
| 102 | + |
0 commit comments