Debian Codegraph @

tests/qunit/resources/mediawiki.template.mustache.test.js

raw symbols SCIP
1 QUnit.module( 'mediawiki.template.mustache', ( hooks ) => {
2
3 hooks.beforeEach( function () {
4 // Stub register some templates
5 this.sandbox.stub( mw.templates, 'get' ).returns( {
6 'test_greeting.mustache': '<div>{{foo}}{{>suffix}}</div>',
7 'test_greeting_suffix.mustache': ' goodbye'
8 } );
9 } );
10
11 QUnit.test( 'render', ( assert ) => {
12 const template = mw.template.get( 'stub', 'test_greeting.mustache' );
13 const partial = mw.template.get( 'stub', 'test_greeting_suffix.mustache' );
14 const data = {
15 foo: 'Hello'
16 };
17 const partials = {
18 suffix: partial
19 };
20
21 const html = template.render( data ).html();
22 assert.strictEqual( html, 'Hello', 'Render without partial' );
23
24 const htmlPartial = template.render( data, partials ).html();
25 assert.strictEqual( htmlPartial, 'Hello goodbye', 'Render with partial' );
26 } );
27 } );