mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-24 07:34:11 +00:00
bb60d5b716
I guess both is fine: either having the default in the gateway (as it was before), or in the renderer (as this patch proposes). I, personally, feel better with having it closer to where it is needed. This way it's not possible to accidentially deliver a model object with an empty title. The renderer will catch this. At the moment we don't know exactly how we will fetch other titles (e.g. "Book"). This change is split from I15611a4 where it was a little misplaced. It also includes a test for the default fallback title. Bug: T213907 Change-Id: I8ec3ddc21a417da7f95feff7b080cbd60d5472e7
35 lines
965 B
JavaScript
35 lines
965 B
JavaScript
import { createStubTitle } from '../stubs';
|
|
import createReferenceGateway from '../../../src/gateway/reference';
|
|
|
|
QUnit.module( 'ext.popups/gateway/reference', {
|
|
beforeEach() {
|
|
mediaWiki.msg = ( key ) => `<${key}>`;
|
|
},
|
|
afterEach() {
|
|
mediaWiki.msg = null;
|
|
}
|
|
} );
|
|
|
|
QUnit.test( 'Reference preview gateway returns the correct data', function ( assert ) {
|
|
const gateway = createReferenceGateway();
|
|
|
|
return gateway.fetchPreviewForTitle( createStubTitle( 1, '', 'cite_note--1' ) ).then( ( result ) => {
|
|
assert.propEqual(
|
|
result,
|
|
{
|
|
url: '#cite_note--1',
|
|
// FIXME: The test should be set up in a way so this contains something.
|
|
extract: undefined,
|
|
type: 'reference'
|
|
}
|
|
);
|
|
} );
|
|
} );
|
|
|
|
QUnit.test( 'Reference preview gateway is abortable', function ( assert ) {
|
|
const gateway = createReferenceGateway(),
|
|
promise = gateway.fetchPreviewForTitle( createStubTitle( 1, '' ) );
|
|
|
|
assert.strictEqual( typeof promise.abort, 'function' );
|
|
} );
|