(opts: TestLayerOptions<LayerT>)
| 212 | * Use `testLayerAsync` if the layer's update flow contains async operations. |
| 213 | */ |
| 214 | export 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). |
nothing calls this directly
no test coverage detected
searching dependent graphs…