mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-12-18 19:00:50 +00:00
5d83c55f5e
Bug: T367248 Change-Id: If4267e083cd6721bdb80d32a84c1fd9306096b50
118 lines
2.7 KiB
JavaScript
118 lines
2.7 KiB
JavaScript
const tables = require( '../../../resources/skins.vector.js/tables.js' ).init;
|
|
|
|
describe( 'tables', () => {
|
|
test( 'wraps table with div', () => {
|
|
document.body.innerHTML = `
|
|
<div class="mw-parser-output">
|
|
<table class="wikitable">
|
|
<tbody><tr><th>table table table</th></tr></tbody>
|
|
</table>
|
|
</div>
|
|
`;
|
|
tables();
|
|
|
|
expect( document.body.innerHTML ).toMatchSnapshot();
|
|
} );
|
|
|
|
test( 'wraps multiple table with div', () => {
|
|
document.body.innerHTML = `
|
|
<div class="mw-parser-output">
|
|
<table class="wikitable">
|
|
<tbody><tr><th>table table table</th></tr></tbody>
|
|
</table>
|
|
<table class="wikitable">
|
|
<table class="wikitable">
|
|
<tbody><tr><th>table table table</th></tr></tbody>
|
|
</table>
|
|
<table class="wikitable">
|
|
<tbody><tr><th>table table table</th></tr></tbody>
|
|
</table>
|
|
</div>
|
|
`;
|
|
tables();
|
|
|
|
expect( document.body.innerHTML ).toMatchSnapshot();
|
|
} );
|
|
|
|
test( 'doesnt wrap nested tables', () => {
|
|
document.body.innerHTML = `
|
|
<div class="mw-parser-output">
|
|
<table class="wikitable">
|
|
<tbody>
|
|
<tr><th>table table table</th></tr>
|
|
<tr><td><table class="wikitable"><tbody><tr><th>table table table</th></tr></tbody></table><td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
`;
|
|
tables();
|
|
|
|
expect( document.body.innerHTML ).toMatchSnapshot();
|
|
} );
|
|
|
|
test( 'doesnt wrap tables that are not wikitables', () => {
|
|
document.body.innerHTML = `
|
|
<div class="mw-parser-output">
|
|
<table>
|
|
<tbody>
|
|
<tr><th>table table table</th></tr>
|
|
<tr><td><table><tbody><tr><th>table table table</th></tr></tbody></table><td></tr>
|
|
</tbody>
|
|
</table>
|
|
<div>
|
|
`;
|
|
tables();
|
|
|
|
expect( document.body.innerHTML ).toMatchSnapshot();
|
|
} );
|
|
|
|
test( 'doesnt wrap tables that already have noresize', () => {
|
|
document.body.innerHTML = `
|
|
<div class="mw-parser-output">
|
|
<div class="noresize">
|
|
<table class="wikitable">
|
|
<tbody>
|
|
<tr><th>table table table</th></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
`;
|
|
tables();
|
|
|
|
expect( document.body.innerHTML ).toMatchSnapshot();
|
|
} );
|
|
|
|
test( 'doesnt wrap tables that are already wrapped', () => {
|
|
document.body.innerHTML = `
|
|
<div class="mw-parser-output">
|
|
<div>
|
|
<table class="wikitable">
|
|
<tbody>
|
|
<tr><th>table table table</th></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
`;
|
|
tables();
|
|
|
|
expect( document.body.innerHTML ).toMatchSnapshot();
|
|
} );
|
|
|
|
test( 'doesnt wrap floated tables', () => {
|
|
document.body.innerHTML = `
|
|
<div class="mw-parser-output">
|
|
<table class="wikitable" style="float:right">
|
|
<tbody>
|
|
<tr><th>table table table</th></tr>
|
|
</tbody>
|
|
</table>
|
|
<div>
|
|
`;
|
|
tables();
|
|
|
|
expect( document.body.innerHTML ).toMatchSnapshot();
|
|
} );
|
|
} );
|