mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-17 05:10:50 +00:00
33 lines
803 B
JavaScript
33 lines
803 B
JavaScript
|
var
|
||
|
testUtils = require( './testUtils.js' ),
|
||
|
CommentItem = require( 'ext.discussionTools.init' ).CommentItem,
|
||
|
HeadingItem = require( 'ext.discussionTools.init' ).HeadingItem;
|
||
|
|
||
|
QUnit.module( 'mw.dt.ThreadItem', testUtils.newEnvironment() );
|
||
|
|
||
|
QUnit.test( '#getAuthorsBelow', function ( assert ) {
|
||
|
var cases = require( '../cases/authors.json' );
|
||
|
|
||
|
function newFromJSON( json ) {
|
||
|
var item;
|
||
|
if ( json.type === 'heading' ) {
|
||
|
item = new HeadingItem();
|
||
|
} else {
|
||
|
item = new CommentItem();
|
||
|
item.author = json.author;
|
||
|
}
|
||
|
item.replies = json.replies.map( newFromJSON );
|
||
|
return item;
|
||
|
}
|
||
|
|
||
|
cases.forEach( function ( caseItem ) {
|
||
|
var threadItem = newFromJSON( caseItem.thread ),
|
||
|
authors = threadItem.getAuthorsBelow();
|
||
|
|
||
|
assert.deepEqual(
|
||
|
authors,
|
||
|
caseItem.expected
|
||
|
);
|
||
|
} );
|
||
|
} );
|