diff --git a/tests/qunit/ext.cite.referencePreviews/createReferenceGateway.test.js b/tests/qunit/ext.cite.referencePreviews/createReferenceGateway.test.js index 3b29364c3..f906ef2cc 100644 --- a/tests/qunit/ext.cite.referencePreviews/createReferenceGateway.test.js +++ b/tests/qunit/ext.cite.referencePreviews/createReferenceGateway.test.js @@ -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 = $( '' ).appendTo( $( '' ).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(); } diff --git a/tests/qunit/ext.cite.referencePreviews/renderer.test.js b/tests/qunit/ext.cite.referencePreviews/renderer.test.js index 9375c9ea7..d20551019 100644 --- a/tests/qunit/ext.cite.referencePreviews/renderer.test.js +++ b/tests/qunit/ext.cite.referencePreviews/renderer.test.js @@ -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( / `<${ 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( /