mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-01 03:26:28 +00:00
52c09788a1
We're probably not going to use it again, and I don't want to make the effort of rewriting it in Id867b3005ebc46906d6df852a525fcaec9e6b19b. Change-Id: I0b02533f7c9b8c1b0df271e03a74063f123d0dff
38 lines
921 B
JavaScript
38 lines
921 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
|
|
);
|
|
} );
|
|
} );
|
|
|
|
// TODO:
|
|
// * getHeading (CommentItem+HeadingItem)
|
|
// * getLinkableTitle (HeadingItem)
|
|
// * newFromJSON (ThreadItem)
|