mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-24 07:34:11 +00:00
actions: Dispatch FETCH_END
... when the gateway request ends, per I62c9cb04. Change-Id: Ifbed65d6b97877e859e81f256fa44344a64fc64f
This commit is contained in:
parent
8b311aa159
commit
3646b04876
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map
vendored
BIN
resources/dist/index.js.map
vendored
Binary file not shown.
|
@ -112,6 +112,11 @@ actions.fetch = function ( gateway, el, started ) {
|
|||
var now = mw.now(),
|
||||
delay;
|
||||
|
||||
dispatch( timedAction( {
|
||||
type: types.FETCH_END,
|
||||
el: el
|
||||
} ) );
|
||||
|
||||
// If the API request has taken longer than the target delay, then
|
||||
// don't delay any further.
|
||||
delay = Math.max(
|
||||
|
|
|
@ -293,7 +293,7 @@ QUnit.test( 'it should delay dispatching the FETCH_COMPLETE action', function (
|
|||
result = {},
|
||||
done = assert.async( 2 );
|
||||
|
||||
assert.expect( 3 );
|
||||
assert.expect( 4 );
|
||||
|
||||
this.fetch();
|
||||
|
||||
|
@ -309,18 +309,31 @@ QUnit.test( 'it should delay dispatching the FETCH_COMPLETE action', function (
|
|||
done();
|
||||
} );
|
||||
|
||||
|
||||
this.waitPromise.then( function () {
|
||||
// Let the wait.then execute to run the dispatch before asserting
|
||||
setTimeout( function () {
|
||||
assert.equal( that.dispatch.callCount, 2, 'dispatch called for start and end' );
|
||||
assert.deepEqual( that.dispatch.getCall( 1 ).args[ 0 ], {
|
||||
assert.equal( that.dispatch.callCount, 3, 'dispatch called for start and end' );
|
||||
assert.deepEqual(
|
||||
that.dispatch.getCall( 1 ).args[ 0 ],
|
||||
{
|
||||
type: 'FETCH_END',
|
||||
el: that.el,
|
||||
timestamp: 250
|
||||
},
|
||||
'It should dispatch the FETCH_END action when the gateway request ends.'
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
that.dispatch.getCall( 2 ).args[ 0 ],
|
||||
{
|
||||
type: 'FETCH_COMPLETE',
|
||||
el: that.el,
|
||||
result: result,
|
||||
delay: 250,
|
||||
timestamp: 250
|
||||
} );
|
||||
},
|
||||
'It should dispatch the FETCH_COMPLETE action when the preview model is resolved.'
|
||||
);
|
||||
|
||||
done();
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue