Page MenuHomeWickedGov Phorge

ReasonField.test.js
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

ReasonField.test.js

'use strict';
const { mount, shallowMount } = require( '@vue/test-utils' );
const ReasonField = require( '../../../resources/src/mediawiki.special.block/components/ReasonField.vue' );
const { mockMwConfigGet } = require( './SpecialBlock.setup.js' );
describe( 'ReasonField', () => {
const testCases = [
{
modelValue: 'Vandalism: Test',
selected: 'Vandalism',
other: 'Test'
}, {
modelValue: 'VandalismTest',
selected: 'other',
other: 'VandalismTest'
}, {
modelValue: 'Test',
selected: 'other',
other: 'Test'
}, {
modelValue: 'Vandalism',
selected: 'Vandalism',
other: ''
}, {
modelValue: '',
selected: 'other',
other: ''
}
];
it.each( testCases )( 'setFieldsFromGiven ($modelValue)', ( { modelValue, selected, other } ) => {
mockMwConfigGet();
// Mocks 'colon-separator' message, the only one used in the component.
mw.msg = jest.fn().mockReturnValue( ': ' );
const wrapper = shallowMount( ReasonField, { propsData: { modelValue } } );
expect( wrapper.vm.selected ).toStrictEqual( selected );
expect( wrapper.vm.other ).toStrictEqual( other );
} );
it( 'should not show edit block reason link if user does not have rights', async () => {
const wrapper = mount( ReasonField );
expect( wrapper.find( '.mw-block-reason-edit' ).exists() ).toBeFalsy();
} );
it( 'should display edit block reason link if user has rights', async () => {
mockMwConfigGet( { blockCanEditInterface: true } );
const wrapper = mount( ReasonField );
expect( wrapper.find( '.mw-block-reason-edit' ).exists() ).toBeTruthy();
} );
} );

File Metadata

Mime Type
text/plain
Expires
Tue, Aug 18, 21:42 (16 h, 5 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
13/9c/fb1f58de0c6502fec4cd17576b6b
Default Alt Text
ReasonField.test.js (1 KB)

Event Timeline