Page MenuHomeWickedGov Phorge

init.test.js
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

init.test.js

'use strict';
describe( 'SpecialBlock init.js', () => {
let targetInput, Vue;
beforeEach( () => {
document.body.innerHTML = '';
const form = document.createElement( 'form' );
form.className = 'mw-htmlform';
document.body.appendChild( form );
targetInput = document.createElement( 'input' );
targetInput.id = 'mw-bi-target';
form.appendChild( targetInput );
mw.Api.prototype.loadMessagesIfMissing = jest.fn().mockResolvedValue( undefined );
Vue = require( 'vue' );
Vue.createMwApp = jest.fn().mockReturnValue( {
use: jest.fn().mockReturnValue( {
mount: jest.fn()
} )
} );
} );
afterEach( () => {
jest.resetModules();
} );
it( 'should give the form the ID mw-block-form', () => {
const mockConfig = {};
mw.config.set = ( key, value ) => {
mockConfig[ key ] = value;
};
require( '../../../resources/src/mediawiki.special.block/init.js' );
expect( document.querySelector( '.mw-htmlform' ).id ).toBe( 'mw-block-form' );
} );
it( 'should do nothing if there is no mw-htmlform', () => {
const htmlForm = document.querySelector( '.mw-htmlform' );
htmlForm.className = 'not-mw-htmlform';
require( '../../../resources/src/mediawiki.special.block/init.js' );
expect( htmlForm.id ).not.toBe( 'mw-block-form' );
expect( mw.Api.prototype.loadMessagesIfMissing ).not.toHaveBeenCalled();
expect( Vue.createMwApp ).not.toHaveBeenCalled();
} );
} );

File Metadata

Mime Type
text/plain
Expires
Aug 17 2026, 16:01 (10 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
1f/3c/9d971b4a11e91bfdf547683ba915
Default Alt Text
init.test.js (1 KB)

Event Timeline