From 594139cf52687b3e5766e2ce747779ab2466b088 Mon Sep 17 00:00:00 2001 From: Georgios Karnas Date: Wed, 5 Jun 2019 18:05:33 -0700 Subject: [PATCH] Unit tests for scenegraph-layer --- .../src/scenegraph-layer/scenegraph-layer.js | 1 + test/modules/layers/index.js | 1 + test/modules/layers/scenegraph-layer.spec.js | 49 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 test/modules/layers/scenegraph-layer.spec.js diff --git a/modules/mesh-layers/src/scenegraph-layer/scenegraph-layer.js b/modules/mesh-layers/src/scenegraph-layer/scenegraph-layer.js index fff07cc612d..4712f319cf1 100644 --- a/modules/mesh-layers/src/scenegraph-layer/scenegraph-layer.js +++ b/modules/mesh-layers/src/scenegraph-layer/scenegraph-layer.js @@ -132,6 +132,7 @@ export default class ScenegraphLayer extends Layer { } finalizeState() { + super.finalizeState(); this._deleteScenegraph(); } diff --git a/test/modules/layers/index.js b/test/modules/layers/index.js index cd0ad25c066..ccf775ce8dc 100644 --- a/test/modules/layers/index.js +++ b/test/modules/layers/index.js @@ -26,6 +26,7 @@ import './polygon-layer.spec'; import './geojson.spec'; import './geojson-layer.spec'; import './simple-mesh-layer.spec'; +import './scenegraph-layer.spec'; import './path-layer/path-layer-vertex.spec'; import './icon-manager.spec'; import './text-layer/font-atlas-utils.spec'; diff --git a/test/modules/layers/scenegraph-layer.spec.js b/test/modules/layers/scenegraph-layer.spec.js new file mode 100644 index 00000000000..d06f3817589 --- /dev/null +++ b/test/modules/layers/scenegraph-layer.spec.js @@ -0,0 +1,49 @@ +// Copyright (c) 2015 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import test from 'tape-catch'; +import {testLayer, generateLayerTests} from '@deck.gl/test-utils'; + +import {ScenegraphLayer} from '@deck.gl/mesh-layers'; + +import * as FIXTURES from 'deck.gl-test/data'; + +test('ScenegraphLayer#tests', t => { + const testCases = generateLayerTests({ + Layer: ScenegraphLayer, + sampleProps: { + data: FIXTURES.points, + getPosition: d => d.COORDINATES, + scenegraph: '' + }, + assert: t.ok, + onBeforeUpdate: ({testCase}) => t.comment(testCase.title), + onAfterUpdate: ({layer, subLayers}) => { + // if (layer.props.mesh) { + // t.ok(layer.getModels().length > 0, 'Layer should have models'); + // } + }, + runDefaultAsserts: false + }); + + testLayer({Layer: ScenegraphLayer, testCases, onError: t.notOk}); + + t.end(); +});