Skip to content

Commit 6d4726f

Browse files
committed
add AbortSignal test
1 parent 9a9b606 commit 6d4726f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/unit/source/custom_source.test.js

+18
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,24 @@ test('CustomSource', (t) => {
184184
sourceCache._addTile(tileID);
185185
});
186186

187+
t.test('loadTile aborts', (t) => {
188+
const tileID = new OverscaledTileID(0, 0, 0, 0, 0);
189+
190+
const loadTile = t.spy(async (tile, {signal}) => {
191+
t.ok(signal, 'AbortSignal is present in loadTile');
192+
signal.addEventListener('abort', () => {
193+
t.pass('AbortSignal was aborted');
194+
t.end();
195+
});
196+
});
197+
198+
const {sourceCache} = createSource(t, {loadTile});
199+
200+
sourceCache.onAdd();
201+
const tile = sourceCache._addTile(tileID);
202+
sourceCache._abortTile(tile);
203+
});
204+
187205
t.test('prepareTile does not change the tile data if it returns undefined', (t) => {
188206
const tileID = new OverscaledTileID(0, 0, 0, 0, 0);
189207
const expectedData = new window.ImageData(512, 512);

0 commit comments

Comments
 (0)