Skip to content

Commit

Permalink
add spec
Browse files Browse the repository at this point in the history
  • Loading branch information
deyihu authored and fuzhenn committed Aug 10, 2023
1 parent 3129d2f commit a150ce7
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 58 deletions.
2 changes: 1 addition & 1 deletion src/renderer/layer/ImageGLRenderable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IS_NODE, extend, isInteger, log2, isNil, isNumber } from '../../core/util';
import { IS_NODE, extend, isInteger, isNil, isNumber } from '../../core/util';
import { createGLContext, createProgram, enableVertexAttrib } from '../../core/util/gl';
import Browser from '../../core/Browser';
import * as mat4 from '../../core/util/mat4';
Expand Down
126 changes: 69 additions & 57 deletions test/geometry/GeometryCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ describe('#GeometryCollection', function () {
}
});

it('miss properties of children #2042', function (done) {
var opts = {
properties: { name: 'hello' }
}
var collection = new maptalks.GeometryCollection([new maptalks.Marker(center)], opts);
var str1 = JSON.stringify(collection.getProperties());
const child = collection.getGeometries()[0];
var str2 = JSON.stringify(child.getProperties());
expect(str1).to.be.equal(str2);
done();
});

describe('creation', function () {

it('normal constructor', function () {
Expand All @@ -106,18 +118,18 @@ describe('#GeometryCollection', function () {
var points = genPoints();
points.forEach(function (p, index) {
p.setSymbol({
'markerType' : 'ellipse',
'markerWidth' : index,
'markerHeight' : index
'markerType': 'ellipse',
'markerWidth': index,
'markerHeight': index
});
});

var collection = new maptalks.GeometryCollection(points);
collection.forEach(function (f, index) {
expect(f.getSymbol()).to.be.eql({
'markerType' : 'ellipse',
'markerWidth' : index,
'markerHeight' : index
'markerType': 'ellipse',
'markerWidth': index,
'markerHeight': index
});
});
});
Expand All @@ -126,9 +138,9 @@ describe('#GeometryCollection', function () {
var points = genPoints();
points.forEach(function (p, index) {
p.setSymbol({
'markerType' : 'ellipse',
'markerWidth' : index,
'markerHeight' : index
'markerType': 'ellipse',
'markerWidth': index,
'markerHeight': index
});
});

Expand All @@ -140,9 +152,9 @@ describe('#GeometryCollection', function () {

c2.forEach(function (f, index) {
expect(f.getSymbol()).to.be.eql({
'markerType' : 'ellipse',
'markerWidth' : index,
'markerHeight' : index
'markerType': 'ellipse',
'markerWidth': index,
'markerHeight': index
});
});
});
Expand All @@ -151,18 +163,18 @@ describe('#GeometryCollection', function () {
var points = genPoints();
points.forEach(function (p, index) {
p.setSymbol({
'markerType' : 'ellipse',
'markerWidth' : index,
'markerHeight' : index
'markerType': 'ellipse',
'markerWidth': index,
'markerHeight': index
});
});

var c = new maptalks.GeometryCollection(points);

var symbol = {
'markerType' : 'square',
'markerWidth' : 10,
'markerHeight' : 10
'markerType': 'square',
'markerWidth': 10,
'markerHeight': 10
};
c.setSymbol(symbol);

Expand All @@ -178,24 +190,24 @@ describe('#GeometryCollection', function () {
var symbols = [];
points.forEach(function (p, index) {
symbols.push({
'markerType' : 'ellipse',
'markerWidth' : index,
'markerHeight' : index
'markerType': 'ellipse',
'markerWidth': index,
'markerHeight': index
});
});

var symbol = {
'children' : symbols
'children': symbols
};
c.setSymbol(symbol);

expect(c.getSymbol()).to.be.eql(symbol);

c.forEach(function (f, index) {
expect(f.getSymbol()).to.be.eql({
'markerType' : 'ellipse',
'markerWidth' : index,
'markerHeight' : index
'markerType': 'ellipse',
'markerWidth': index,
'markerHeight': index
});
});
});
Expand All @@ -204,20 +216,20 @@ describe('#GeometryCollection', function () {
var points = genPoints();
var c = new maptalks.GeometryCollection(points);
c.setSymbol({
'markerType' : 'ellipse',
'markerWidth' : 20,
'markerHeight' : 20
'markerType': 'ellipse',
'markerWidth': 20,
'markerHeight': 20
});

c.updateSymbol({
'opacity' : 1
'opacity': 1
});

var expected = {
'markerType' : 'ellipse',
'markerWidth' : 20,
'markerHeight' : 20,
'opacity' : 1
'markerType': 'ellipse',
'markerWidth': 20,
'markerHeight': 20,
'opacity': 1
};

expect(c.getSymbol()).to.be.eql(expected);
Expand All @@ -231,7 +243,7 @@ describe('#GeometryCollection', function () {
describe('collection add to layer', function () {
var layers = [
new maptalks.VectorLayer('geometrycollection_test_svg'),
new maptalks.VectorLayer('geometrycollection_test_canvas', { 'render':'canvas' })
new maptalks.VectorLayer('geometrycollection_test_canvas', { 'render': 'canvas' })
];
layers.forEach(function (layer) {
it('can be add to layer', function () {
Expand All @@ -255,14 +267,14 @@ describe('#GeometryCollection', function () {
var points = genPoints();
var collection = new maptalks.GeometryCollection(points);
var symbol = {
'markerFile' : 'test',
'markerWidth' : 40,
'markerHeight' : 50
'markerFile': 'test',
'markerWidth': 40,
'markerHeight': 50
};
var expected = {
'markerFile' : 'test',
'markerWidth' : 40,
'markerHeight' : 50
'markerFile': 'test',
'markerWidth': 40,
'markerHeight': 50
};

collection.setSymbol(symbol);
Expand All @@ -284,7 +296,7 @@ describe('#GeometryCollection', function () {

var layers = [
new maptalks.VectorLayer('geometrycollection_test_svg'),
new maptalks.VectorLayer('geometrycollection_test_canvas', { 'render':'canvas' })
new maptalks.VectorLayer('geometrycollection_test_canvas', { 'render': 'canvas' })
];
layers.forEach(function (layer) {
it('can be updated after added to layer', function () {
Expand Down Expand Up @@ -342,31 +354,31 @@ describe('#GeometryCollection', function () {
function genPoints() {
return [
new maptalks.Marker([0, 0], {
properties : {
'foo1' : 1,
'foo2' : 'test1',
'foo3' : true
properties: {
'foo1': 1,
'foo2': 'test1',
'foo3': true
}
}),
new maptalks.Marker([0, 0], {
properties : {
'foo1' : 2,
'foo2' : 'test2',
'foo3' : false
properties: {
'foo1': 2,
'foo2': 'test2',
'foo3': false
}
}),
new maptalks.Marker([0, 0], {
properties : {
'foo1' : 3,
'foo2' : 'test3',
'foo3' : true
properties: {
'foo1': 3,
'foo2': 'test3',
'foo3': true
}
}),
new maptalks.Marker([0, 0], {
properties : {
'foo1' : 4,
'foo2' : 'test4',
'foo3' : true
properties: {
'foo1': 4,
'foo2': 'test4',
'foo3': true
}
})
];
Expand Down

0 comments on commit a150ce7

Please sign in to comment.