MCPcopy Index your code
hub / github.com/visgl/deck.gl / testLayerAsync

Function testLayerAsync

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

Source from the content-addressed store, hash-verified

248 * Each test case is awaited until the layer's isLoaded flag is true.
249 */
250export async function testLayerAsync<LayerT extends Layer>(
251 opts: TestLayerOptions<LayerT>
252): Promise<void> {
253 const {Layer, testCases = [], spies = [], onError = defaultOnError, createSpy, resetSpy} = opts;
254
255 const resources = setupLayerTests(`testing ${Layer.layerName}`, opts);
256
257 let layer = new Layer();
258 // Run successive update tests
259 for (const testCase of testCases) {
260 // Save old state before update
261 const oldState = {...layer.state};
262
263 const {layer: newLayer, spyMap} = runLayerTestUpdate(
264 testCase,
265 resources,
266 layer,
267 spies,
268 createSpy
269 );
270
271 runLayerTestPostUpdateCheck(testCase, newLayer, oldState, spyMap);
272
273 while (!newLayer.isLoaded) {
274 await update(resources);
275 runLayerTestPostUpdateCheck(testCase, newLayer, oldState, spyMap);
276 }
277
278 // Reset spies between test cases
279 Object.keys(spyMap).forEach(k => resetSpy(spyMap[k]));
280 layer = newLayer;
281 }
282
283 // Use async cleanup to allow pending luma.gl async operations to complete
284 const error = await cleanupAfterLayerTestsAsync(resources);
285 if (error) {
286 onError(error, `${Layer.layerName} should delete all resources`);
287 }
288}
289
290function setupLayerTests(
291 testTitle: string,

Callers

nothing calls this directly

Calls 6

setupLayerTestsFunction · 0.85
runLayerTestUpdateFunction · 0.85
updateFunction · 0.70
onErrorFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…