Merge "Special:Upload should not crash on failing previews"
[mediawiki.git] / tests / qunit / suites / resources / mediawiki / mediawiki.messagePoster.factory.test.js
blobb3c4beeb4e9d1503429547e3e0f12a6e74f094ed
1 ( function ( mw ) {
2 var TEST_MODEL = 'test-content-model';
4 QUnit.module( 'mediawiki.messagePoster', QUnit.newMwEnvironment( {
5 teardown: function () {
6 mw.messagePoster.factory.unregister( TEST_MODEL );
8 } ) );
10 QUnit.test( 'register', 2, function ( assert ) {
11 var testMessagePosterConstructor = function () {};
13 mw.messagePoster.factory.register( TEST_MODEL, testMessagePosterConstructor );
14 assert.strictEqual(
15 mw.messagePoster.factory.contentModelToClass[ TEST_MODEL ],
16 testMessagePosterConstructor,
17 'Constructor is registered'
20 assert.throws(
21 function () {
22 mw.messagePoster.factory.register( TEST_MODEL, testMessagePosterConstructor );
24 new RegExp( 'Content model "' + TEST_MODEL + '" is already registered' ),
25 'Throws exception is same model is registered a second time'
27 } );
28 }( mediaWiki ) );