MCPcopy
hub / github.com/visgl/deck.gl / testLayer

Function testLayer

modules/test-utils/src/lifecycle-test.ts:214–244  ·  view source on GitHub ↗
(opts: TestLayerOptions<LayerT>)

Source from the content-addressed store, hash-verified

212 * Use `testLayerAsync` if the layer's update flow contains async operations.
213 */
214export function testLayer<LayerT extends Layer>(opts: TestLayerOptions<LayerT>): void {
215 const {Layer, testCases = [], spies = [], onError = defaultOnError, createSpy, resetSpy} = opts;
216
217 const resources = setupLayerTests(`testing ${Layer.layerName}`, opts);
218
219 let layer = new Layer();
220 // Run successive update tests
221 for (const testCase of testCases) {
222 // Save old state before update
223 const oldState = {...layer.state};
224
225 const {layer: newLayer, spyMap} = runLayerTestUpdate(
226 testCase,
227 resources,
228 layer,
229 spies,
230 createSpy
231 );
232
233 runLayerTestPostUpdateCheck(testCase, newLayer, oldState, spyMap);
234
235 // Reset spies between test cases
236 Object.keys(spyMap).forEach(k => resetSpy(spyMap[k]));
237 layer = newLayer;
238 }
239
240 const error = cleanupAfterLayerTests(resources);
241 if (error) {
242 onError(error, `${Layer.layerName} should delete all resources`);
243 }
244}
245
246/**
247 * Initialize and updates a layer over a sequence of scenarios (test cases).

Callers

nothing calls this directly

Calls 5

setupLayerTestsFunction · 0.85
runLayerTestUpdateFunction · 0.85
cleanupAfterLayerTestsFunction · 0.85
onErrorFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…