3 QUnit.module( 'mediawiki.template', {
7 return 'abc default compiler';
11 // Register some template compiler languages
12 mw.template.registerCompiler( 'abc', abcCompiler );
13 mw.template.registerCompiler( 'xyz', {
14 compile: function () {
15 return 'xyz compiler';
19 // Stub register some templates
20 this.sandbox.stub( mw.templates, 'get' ).returns( {
21 'test_templates_foo.xyz': 'goodbye',
22 'test_templates_foo.abc': 'thankyou'
27 QUnit.test( 'add', 1, function ( assert ) {
30 mw.template.add( 'module', 'test_templates_foo', 'hello' );
32 'When no prefix throw exception'
36 QUnit.test( 'compile', 1, function ( assert ) {
39 mw.template.compile( '{{foo}}', 'rainbow' );
41 'Unknown compiler names throw exceptions'
45 QUnit.test( 'get', 4, function ( assert ) {
46 assert.strictEqual( mw.template.get( 'test.mediawiki.template', 'test_templates_foo.xyz' ), 'xyz compiler' );
47 assert.strictEqual( mw.template.get( 'test.mediawiki.template', 'test_templates_foo.abc' ), 'abc default compiler' );
50 mw.template.get( 'this.should.not.exist', 'hello' );
52 'When bad module name given throw error.'
57 mw.template.get( 'mediawiki.template', 'hello' );
59 'The template hello should not exist in the mediawiki.templates module and should throw an exception.'