Debian Codegraph @

tests/jest/mediawiki.special.block/TargetBlockLog.test.js

raw symbols SCIP
1 'use strict';
2
3 const { mount, flushPromises } = require( '@vue/test-utils' );
4 const { mockMwApiGet } = require( './SpecialBlock.setup.js' );
5 const TargetBlockLog = require( '../../../resources/src/mediawiki.special.block/components/TargetBlockLog.vue' );
6
7 beforeAll( () => mockMwApiGet() );
8
9 describe( 'TargetBlockLog', () => {
10 it( 'should show a table with one row when given a user with one block', async () => {
11 const wrapper = mount( TargetBlockLog, {
12 propsData: { targetUser: 'ExampleUser' }
13 } );
14 await flushPromises();
15 // Test: The table should exist
16 expect( wrapper.find( '.cdx-table__table' ).exists() ).toBeTruthy();
17 const rows = wrapper.findAll( '.cdx-table__table tbody tr' );
18 // Test: The table tbody should have one row
19 expect( rows ).toHaveLength( 1 );
20 } );
21 it( 'should show a table with the no-previous-blocks message when given a user with no blocks', async () => {
22 const wrapper = mount( TargetBlockLog, {
23 propsData: { targetUser: 'NeverBlocked' }
24 } );
25 await flushPromises();
26 // Test: The table should exist
27 expect( wrapper.find( '.cdx-table__table' ).exists() ).toBeTruthy();
28 const rows = wrapper.findAll( '.cdx-table__table tbody tr' );
29 // Test: The table tbody should have one row
30 expect( rows ).toHaveLength( 1 );
31 // Test: The row should contain the no-previous-blocks message
32 expect( rows[ 0 ].text() ).toContain( 'block-user-no-previous-blocks' );
33 } );
34 it( 'should show a table with ten rows, and a show more link, when given a user with more than ten blocks', async () => {
35 const wrapper = mount( TargetBlockLog, {
36 propsData: { targetUser: 'BlockedALot' }
37 } );
38 await flushPromises();
39 // Test: The table should exist
40 expect( wrapper.find( '.cdx-table__table' ).exists() ).toBeTruthy();
41 const rows = wrapper.findAll( '.cdx-table__table tbody tr' );
42 // Test: The table tbody should have ten rows
43 expect( rows ).toHaveLength( 10 );
44 // Test: The show more link should exist
45 expect( wrapper.find( '.mw-block-fulllog' ).exists() ).toBeTruthy();
46 } );
47 } );