#= require ultimate/underscore/underscore #= require ultimate/underscore/underscore.string #= require ultimate/helpers/tag module "Ultimate.Helpers.Tag" _.extend @, Ultimate.Helpers.Tag test "tag_options", -> strictEqual tag_options(), "" strictEqual tag_options({}), "" ok /title="Some title"/.test tag_options(class: "some-class", title: "Some title") equal tag_options(class: ["song", "play>"]), ' class="song play>"' equal tag_options(disabled: true, itemscope: false, multiple: true, readonly: true), ' disabled="disabled" multiple="multiple" readonly="readonly"' equal tag_options(data: {remote: true}, role: "ajax"), ' data-remote="true" role="ajax"' equal tag_options(data: {inner: {section: true}}), ' data-inner="{"section":true}"' equal tag_options(data: {inner: {section: true}}, false), ' data-inner="{"section":true}"' equal tag_options(included: ''), ' included=""' test "tag", -> equal tag('br'), '
' equal tag('br', null, true), '
' equal tag('input', type: 'text', disabled: true), '' equal tag('img', src: 'open & shut.png'), '' equal tag("img", {src: "open & shut.png"}, false, false), '' equal tag("div", data: {name: 'Stephen', city_state: ['Chicago', 'IL']}), '
' test "content_tag", -> equal content_tag('div', '', class: ['some', 'class']), '
' equal content_tag('div', '', class: 'some class'), '
<Inner content>
' equal content_tag('div', '', class: 'some class', false), '
' equal content_tag('div', class: 'some class', -> ''), '
<Inner content>
' equal content_tag('div', class: 'some class', false, -> ''), '
<Inner content>
' test "cdata_section", -> equal cdata_section(""), "]]>" equal cdata_section("hello]]>world"), "world]]>" equal cdata_section("hello]]>world]]>again"), "world]]]]>again]]>" test "concat_class", -> strictEqual concat_class(), '' strictEqual concat_class(null), '' strictEqual concat_class([]), '' equal concat_class('lol', 0), 'lol' equal concat_class(' lol ', false, ' wow '), 'lol wow' equal concat_class('lol', null, 'rofl lol wow ', ' wow '), 'lol rofl wow' equal concat_class([['lol', [null]], 'rofl lol wow '], ' wow '), 'lol rofl wow' test "selectorToHtml", -> equal selectorToHtml(''), '' equal selectorToHtml('.lol'), '
' equal selectorToHtml('tr.lol'), '' equal selectorToHtml('tr.lol#rofl'), '' equal selectorToHtml('#rofl.lol'), '
' equal selectorToHtml('.lol.wow'), '
' equal selectorToHtml('.wow#rofl.lol'), '
' # equal selectorToHtml('h1.one+p.two'), '

'