var assert = require('assert'); var HoganJsUtils = new (require('../src/hoganjs-utils.js').HoganJsUtils)(); var diffParser = require('../src/diff-parser.js').DiffParser; describe('HoganJsUtils', function() { describe('render', function() { var emptyDiffHtml = '
{{myName}}
'); var config = {templates: {'generic-empty-diff': emptyDiffTemplate}}; var hoganUtils = new (require('../src/hoganjs-utils.js').HoganJsUtils)(config); var result = hoganUtils.render('generic', 'empty-diff', {myName: 'Rodrigo Fernandes'}); assert.equal('Rodrigo Fernandes
', result); }); it('should allow templates to be overridden with uncompiled templates', function() { var emptyDiffTemplate = '{{myName}}
'; var config = {rawTemplates: {'generic-empty-diff': emptyDiffTemplate}}; var hoganUtils = new (require('../src/hoganjs-utils.js').HoganJsUtils)(config); var result = hoganUtils.render('generic', 'empty-diff', {myName: 'Rodrigo Fernandes'}); assert.equal('Rodrigo Fernandes
', result); }); it('should allow templates to be overridden giving priority to compiled templates', function() { var emptyDiffTemplate = HoganJsUtils.compile('{{myName}}
'); var emptyDiffTemplateUncompiled = 'Not used!
'; var config = { templates: {'generic-empty-diff': emptyDiffTemplate}, rawTemplates: {'generic-empty-diff': emptyDiffTemplateUncompiled} }; var hoganUtils = new (require('../src/hoganjs-utils.js').HoganJsUtils)(config); var result = hoganUtils.render('generic', 'empty-diff', {myName: 'Rodrigo Fernandes'}); assert.equal('Rodrigo Fernandes
', result); }); }); });