From 8f0ae21eca7546a5f783d12e5142bd1a364559f1 Mon Sep 17 00:00:00 2001 From: WMDE-Fisch Date: Thu, 19 Dec 2024 18:30:11 +0100 Subject: [PATCH] [qunit] Use strict and wrap test scope Wrapping the test mainly to avoid that declared vars or functions bleed into other tests. Includes lint auto-fixes Change-Id: Ia4577f7496ddecf4985525de674ade46f53e03a6 --- .../createReferenceGateway.test.js | 310 +++++++++--------- .../isReferencePreviewsEnabled.test.js | 193 +++++------ .../renderer.test.js | 164 ++++----- 3 files changed, 344 insertions(+), 323 deletions(-) diff --git a/tests/qunit/ext.cite.referencePreviews/createReferenceGateway.test.js b/tests/qunit/ext.cite.referencePreviews/createReferenceGateway.test.js index f906ef2cc..740346e17 100644 --- a/tests/qunit/ext.cite.referencePreviews/createReferenceGateway.test.js +++ b/tests/qunit/ext.cite.referencePreviews/createReferenceGateway.test.js @@ -1,174 +1,186 @@ -function createStubTitle( fragment = null ) { - return { - getFragment() { - return fragment; - } - }; -} +'use strict'; -( mw.loader.getModuleNames().indexOf( 'ext.popups.main' ) !== -1 ? - QUnit.module : - QUnit.module.skip )( 'ext.cite.referencePreviews#createReferenceGateway', { - 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 ) - ); - - this.$references = $( '