mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-09-23 10:21:11 +00:00
Remove a small piece of unused code from reference.js
Turns out this was only in place because the test was (intentionally) incomplete. But it's dead code in production. Let's get rid of it. Change-Id: Ieeb145b6972dceb7eeda3a167d907b680d5c3ce4
This commit is contained in:
parent
8a08a88f66
commit
5d2c5aeaa1
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map.json
vendored
BIN
resources/dist/index.js.map.json
vendored
Binary file not shown.
|
@ -70,7 +70,8 @@ export default function createReferenceGateway() {
|
|||
extract: $referenceText.html(),
|
||||
type: previewTypes.TYPE_REFERENCE,
|
||||
referenceType: scrapeReferenceType( $referenceText ),
|
||||
sourceElementId: el && el.parentNode && el.parentNode.id
|
||||
// Note: Even the top-most HTMLHtmlElement is guaranteed to have a parent.
|
||||
sourceElementId: el.parentNode.id
|
||||
};
|
||||
|
||||
return $.Deferred().resolve( model ).promise( { abort() {} } );
|
||||
|
|
|
@ -41,7 +41,8 @@ QUnit.module( 'ext.popups/gateway/reference', {
|
|||
},
|
||||
afterEach() {
|
||||
mw.msg = null;
|
||||
|
||||
mw.message = null;
|
||||
this.$sourceElement.parent().remove();
|
||||
this.$references.remove();
|
||||
}
|
||||
} );
|
||||
|
@ -50,7 +51,7 @@ QUnit.test( 'Reference preview gateway returns the correct data', function ( ass
|
|||
const gateway = createReferenceGateway(),
|
||||
title = createStubTitle( 1, 'Foo', 'cite note-1' );
|
||||
|
||||
return gateway.fetchPreviewForTitle( title ).then( ( result ) => {
|
||||
return gateway.fetchPreviewForTitle( title, this.$sourceElement[ 0 ] ).then( ( result ) => {
|
||||
assert.propEqual(
|
||||
result,
|
||||
{
|
||||
|
@ -58,7 +59,7 @@ QUnit.test( 'Reference preview gateway returns the correct data', function ( ass
|
|||
extract: 'Footnote 1',
|
||||
type: 'reference',
|
||||
referenceType: null,
|
||||
sourceElementId: undefined
|
||||
sourceElementId: 'cite_ref-1'
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
@ -68,7 +69,7 @@ QUnit.test( 'Reference preview gateway accepts alternative text node class name'
|
|||
const gateway = createReferenceGateway(),
|
||||
title = createStubTitle( 1, 'Foo', 'cite note-2' );
|
||||
|
||||
return gateway.fetchPreviewForTitle( title ).then( ( result ) => {
|
||||
return gateway.fetchPreviewForTitle( title, this.$sourceElement[ 0 ] ).then( ( result ) => {
|
||||
assert.propEqual(
|
||||
result,
|
||||
{
|
||||
|
@ -76,7 +77,7 @@ QUnit.test( 'Reference preview gateway accepts alternative text node class name'
|
|||
extract: '<cite class="journal web unknown">Footnote 2</cite>',
|
||||
type: 'reference',
|
||||
referenceType: 'web',
|
||||
sourceElementId: undefined
|
||||
sourceElementId: 'cite_ref-1'
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
@ -86,7 +87,7 @@ QUnit.test( 'Reference preview gateway accepts duplicated types', function ( ass
|
|||
const gateway = createReferenceGateway(),
|
||||
title = createStubTitle( 1, 'Foo', 'cite note-3' );
|
||||
|
||||
return gateway.fetchPreviewForTitle( title ).then( ( result ) => {
|
||||
return gateway.fetchPreviewForTitle( title, this.$sourceElement[ 0 ] ).then( ( result ) => {
|
||||
assert.propEqual(
|
||||
result,
|
||||
{
|
||||
|
@ -94,7 +95,7 @@ QUnit.test( 'Reference preview gateway accepts duplicated types', function ( ass
|
|||
extract: '<cite class="news">Footnote 3</cite><cite class="news citation"></cite><cite class="citation"></cite>',
|
||||
type: 'reference',
|
||||
referenceType: 'news',
|
||||
sourceElementId: undefined
|
||||
sourceElementId: 'cite_ref-1'
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
@ -104,7 +105,7 @@ QUnit.test( 'Reference preview gateway ignores conflicting types', function ( as
|
|||
const gateway = createReferenceGateway(),
|
||||
title = createStubTitle( 1, 'Foo', 'cite note-4' );
|
||||
|
||||
return gateway.fetchPreviewForTitle( title ).then( ( result ) => {
|
||||
return gateway.fetchPreviewForTitle( title, this.$sourceElement[ 0 ] ).then( ( result ) => {
|
||||
assert.propEqual(
|
||||
result,
|
||||
{
|
||||
|
@ -112,7 +113,7 @@ QUnit.test( 'Reference preview gateway ignores conflicting types', function ( as
|
|||
extract: '<cite class="news">Footnote 4</cite><cite class="web"></cite>',
|
||||
type: 'reference',
|
||||
referenceType: 'news',
|
||||
sourceElementId: undefined
|
||||
sourceElementId: 'cite_ref-1'
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
@ -140,7 +141,7 @@ QUnit.test( 'Reference preview gateway rejects non-existing references', functio
|
|||
const gateway = createReferenceGateway(),
|
||||
title = createStubTitle( 1, 'Foo', 'undefined' );
|
||||
|
||||
return gateway.fetchPreviewForTitle( title ).then( () => {
|
||||
return gateway.fetchPreviewForTitle( title, this.$sourceElement[ 0 ] ).then( () => {
|
||||
assert.ok( false, 'It should not resolve' );
|
||||
} ).catch( ( reason, result ) => {
|
||||
assert.propEqual( result, { textStatus: 'abort', xhr: { readyState: 0 } } );
|
||||
|
@ -151,7 +152,7 @@ QUnit.test( 'Reference preview gateway rejects all-whitespace references', funct
|
|||
const gateway = createReferenceGateway(),
|
||||
title = createStubTitle( 1, 'Foo', 'cite note-5' );
|
||||
|
||||
return gateway.fetchPreviewForTitle( title ).then( () => {
|
||||
return gateway.fetchPreviewForTitle( title, this.$sourceElement[ 0 ] ).then( () => {
|
||||
assert.ok( false, 'It should not resolve' );
|
||||
} ).catch( ( reason, result ) => {
|
||||
assert.propEqual( result, { textStatus: 'abort', xhr: { readyState: 0 } } );
|
||||
|
@ -161,7 +162,7 @@ QUnit.test( 'Reference preview gateway rejects all-whitespace references', funct
|
|||
QUnit.test( 'Reference preview gateway is abortable', function ( assert ) {
|
||||
const gateway = createReferenceGateway(),
|
||||
title = createStubTitle( 1, 'Foo', 'cite note-1' ),
|
||||
promise = gateway.fetchPreviewForTitle( title );
|
||||
promise = gateway.fetchPreviewForTitle( title, this.$sourceElement[ 0 ] );
|
||||
|
||||
assert.strictEqual( typeof promise.abort, 'function' );
|
||||
} );
|
||||
|
|
|
@ -42,6 +42,9 @@ QUnit.module( 'ext.popups#renderer', {
|
|||
this.sandbox.stub( constants.default, 'BRACKETED_DEVICE_PIXEL_RATIO' ).value( 1 );
|
||||
|
||||
mw.msg = ( key ) => `<${key}>`;
|
||||
mw.message = ( key ) => {
|
||||
return { exists: () => !key.endsWith( 'generic' ), text: () => `<${key}>` };
|
||||
};
|
||||
|
||||
mw.html = {
|
||||
escape: ( str ) => str && str.replace( /'/g, ''' ).replace( /</g, '<' )
|
||||
|
@ -60,6 +63,7 @@ QUnit.module( 'ext.popups#renderer', {
|
|||
// Restore getElementsById to its original state.
|
||||
document.getElementById = this.getElementById;
|
||||
mw.msg = null;
|
||||
mw.message = null;
|
||||
mw.html = null;
|
||||
}
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue