mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2025-01-10 04:24:31 +00:00
[qunit] Use more stubs for test setup
Change-Id: I73883397f107aca92b8e1808ec1d8dacd391971f
This commit is contained in:
parent
175ad76a08
commit
589e77cbfc
|
@ -9,13 +9,12 @@ function createStubTitle( fragment = null ) {
|
||||||
( mw.loader.getModuleNames().indexOf( 'ext.popups.main' ) !== -1 ?
|
( mw.loader.getModuleNames().indexOf( 'ext.popups.main' ) !== -1 ?
|
||||||
QUnit.module :
|
QUnit.module :
|
||||||
QUnit.module.skip )( 'ext.cite.referencePreviews#createReferenceGateway', {
|
QUnit.module.skip )( 'ext.cite.referencePreviews#createReferenceGateway', {
|
||||||
beforeEach() {
|
beforeEach: function () {
|
||||||
// FIXME: Is this needed?
|
this.sandbox.stub( mw, 'msg', ( key ) => `<${ key }>` );
|
||||||
// global.CSS = {
|
this.sandbox.stub( mw, 'message', ( key ) => ( {
|
||||||
// escape: ( str ) => $.escapeSelector( str )
|
exists: () => !key.endsWith( 'generic' ),
|
||||||
// };
|
text: () => `<${ key }>`
|
||||||
mw.msg = ( key ) => `<${ key }>`;
|
} ) );
|
||||||
mw.message = ( key ) => ( { exists: () => !key.endsWith( 'generic' ), text: () => `<${ key }>` } );
|
|
||||||
|
|
||||||
this.$sourceElement = $( '<a>' ).appendTo(
|
this.$sourceElement = $( '<a>' ).appendTo(
|
||||||
$( '<sup>' ).attr( 'id', 'cite_ref-1' ).appendTo( document.body )
|
$( '<sup>' ).attr( 'id', 'cite_ref-1' ).appendTo( document.body )
|
||||||
|
@ -49,8 +48,6 @@ function createStubTitle( fragment = null ) {
|
||||||
).appendTo( document.body );
|
).appendTo( document.body );
|
||||||
},
|
},
|
||||||
afterEach() {
|
afterEach() {
|
||||||
mw.msg = null;
|
|
||||||
mw.message = null;
|
|
||||||
this.$sourceElement.parent().remove();
|
this.$sourceElement.parent().remove();
|
||||||
this.$references.remove();
|
this.$references.remove();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,18 +7,13 @@ const previewTypes = { TYPE_REFERENCE: 'reference' };
|
||||||
before() {
|
before() {
|
||||||
createReferencePreview = require( 'ext.cite.referencePreviews' ).private.createReferencePreview;
|
createReferencePreview = require( 'ext.cite.referencePreviews' ).private.createReferencePreview;
|
||||||
},
|
},
|
||||||
beforeEach() {
|
beforeEach: function () {
|
||||||
mw.msg = ( key ) => `<${ key }>`;
|
this.sandbox.stub( mw, 'msg', ( key ) => `<${ key }>` );
|
||||||
mw.message = ( key ) => ( { exists: () => !key.endsWith( 'generic' ), text: () => `<${ key }>` } );
|
this.sandbox.stub( mw, 'message', ( key ) => ( {
|
||||||
|
exists: () => !key.endsWith( 'generic' ),
|
||||||
mw.html = {
|
text: () => `<${ key }>`
|
||||||
escape: ( str ) => str && str.replace( /'/g, ''' ).replace( /</g, '<' )
|
} ) );
|
||||||
};
|
this.sandbox.stub( mw.html, 'escape', ( str ) => str && str.replace( /'/g, ''' ).replace( /</g, '<' ) );
|
||||||
},
|
|
||||||
afterEach() {
|
|
||||||
mw.msg = null;
|
|
||||||
mw.message = null;
|
|
||||||
mw.html = null;
|
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue