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