mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-13 09:03:35 +00:00
efe95494a8
Now it detect signatures generated by en.wp's {{Undated}} template, and signatures of people who do weird stuff to the timestamps. Bug: T275938 Change-Id: I27b07f6786ca5433a3c02a5fe68e4716d41401bb
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
var
|
|
testUtils = require( './testUtils.js' ),
|
|
utils = require( 'ext.discussionTools.init' ).utils;
|
|
|
|
QUnit.module( 'mw.dt.utils', testUtils.newEnvironment() );
|
|
|
|
QUnit.test( '#linearWalk', function ( assert ) {
|
|
var cases = require( '../cases/linearWalk.json' );
|
|
|
|
cases.forEach( function ( caseItem ) {
|
|
var
|
|
$dom = mw.template.get( 'test.DiscussionTools', caseItem.dom ).render(),
|
|
expected = require( caseItem.expected ),
|
|
expectedBackwards,
|
|
actual = [],
|
|
actualBackwards = [];
|
|
|
|
utils.linearWalk( $dom[ 0 ].parentNode, function ( event, node ) {
|
|
actual.push( event + ' ' + node.nodeName.toLowerCase() + '(' + node.nodeType + ')' );
|
|
} );
|
|
|
|
utils.linearWalkBackwards( $dom[ 0 ].parentNode, function ( event, node ) {
|
|
actualBackwards.push( event + ' ' + node.nodeName.toLowerCase() + '(' + node.nodeType + ')' );
|
|
} );
|
|
|
|
assert.deepEqual( actual, expected, caseItem.name );
|
|
|
|
expectedBackwards = expected.slice().reverse().map( function ( a ) {
|
|
return ( a.substr( 0, 5 ) === 'enter' ? 'leave' : 'enter' ) + a.substr( 5 );
|
|
} );
|
|
assert.deepEqual( actualBackwards, expectedBackwards, caseItem.name + ' (backwards)' );
|
|
|
|
// Uncomment this to get updated content for the JSON files, for copy/paste:
|
|
// console.log( JSON.stringify( actual, null, 2 ) );
|
|
} );
|
|
} );
|