mediawiki-extensions-Discus.../tests/qunit/ThreadItem.test.js
Bartosz Dziewoński 52c09788a1 Remove unused JS version of ThreadItem#getTranscludedFrom
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
2021-12-17 00:54:37 +00:00

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)