( opts: TestLayerOptions<LayerT> )
| 248 | * Each test case is awaited until the layer's isLoaded flag is true. |
| 249 | */ |
| 250 | export 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 | |
| 290 | function setupLayerTests( |
| 291 | testTitle: string, |
nothing calls this directly
no test coverage detected
searching dependent graphs…