maplibre-gl
Version:
BSD licensed community fork of mapbox-gl, a WebGL interactive maps library
65 lines (61 loc) • 1.64 kB
text/typescript
import group from './group_by_layout';
describe('group by layout', () => {
test('group layers whose ref properties are identical', () => {
const a = {
'id': 'parent',
'type': 'line'
};
const b = {
'id': 'child',
'type': 'line'
};
expect(group([a, b], {})).toEqual([[a, b]]);
expect(group([a, b], {})[0][0]).toBe(a);
expect(group([a, b], {})[0][1]).toBe(b);
});
test('group does not group unrelated layers', () => {
expect(group([
{
'id': 'parent',
'type': 'line'
},
{
'id': 'child',
'type': 'fill'
}
], {})).toEqual([
[{
'id': 'parent',
'type': 'line'
}], [{
'id': 'child',
'type': 'fill'
}]
]);
});
test('group works even for differing layout key orders', () => {
expect(group([
{
'id': 'parent',
'type': 'line',
'layout': {'a': 1, 'b': 2}
},
{
'id': 'child',
'type': 'line',
'layout': {'b': 2, 'a': 1}
}
], {})).toEqual([[
{
'id': 'parent',
'type': 'line',
'layout': {'a': 1, 'b': 2}
},
{
'id': 'child',
'type': 'line',
'layout': {'b': 2, 'a': 1}
}
]]);
});
});