const assert = require('assert');
const hbs = require('handlebars').create();
const helpers = require('..');
helpers.html({ handlebars: hbs });
const locals = {data: [{aaa: 'AAA', bbb: 'BBB'}, {aaa: 'CCC', bbb: 'DDD'}]};
let actual;
describe('html', function() {
describe('attr', function() {
it('should strip html from a string.', function() {
const actual = hbs.compile('
')({foo: 'btn'});
assert.equal(actual, '');
assert.equal(hbs.compile('{{attr}}')(), '');
});
});
describe('css', function() {
it('should return an empty string when no context is passed:', function() {
assert.equal(hbs.compile('{{{css}}}')(), '');
});
it('should use a path passed as a string', function() {
const actual = hbs.compile('{{{css "abc.css"}}}')();
assert.equal(actual, '');
});
it('should use options.assets', function() {
const actual = hbs.compile('{{{css "abc.css"}}}')({options: {assets: 'foo'}});
assert.equal(actual, '');
});
it('should ensure that options.assets is a string', function() {
const actual = hbs.compile('{{{css "abc.css"}}}')({options: {assets: null}});
assert.equal(actual, '');
});
it('should not use options.assets when passing in an absolute url', function() {
const actual = hbs.compile('{{{css "https://abc.com/bar.css"}}}')({options: {assets: 'foo'}});
assert.equal(actual, '');
});
it('should use the `href` attribute on the hash', function() {
actual = hbs.compile('{{{css href=""}}}')();
assert.equal(actual, '');
actual = hbs.compile('{{{css href="abc.css"}}}')();
assert.equal(actual, '');
});
it('should create multiple tags from an array passed on the context:', function() {
const ctx = {styles: ['a.css', 'bcss', 'c.css'] };
assert.equal(hbs.compile('{{{css styles}}}')(ctx), [
'',
'',
''
].join('\n'));
});
it('should create a less tag (TODO: only works with array format)', function() {
const ctx = {styles: ['a.less'] };
assert.equal(hbs.compile('{{{css styles}}}')(ctx), '');
});
});
describe('ul', function() {
it('should should return an unordered list', function() {
const fn = hbs.compile('{{#ul data class="names"}}{{aaa}} {{bbb}}{{/ul}}');
assert.equal(fn(locals), '
AAA BBB
\n
CCC DDD
');
});
});
describe('ol', function() {
it('should should return an ordered list', function() {
const fn = hbs.compile('{{#ol data class="names"}}{{aaa}} {{bbb}}{{/ol}}');
assert.equal(fn(locals), '