Files
atom/spec/stdlib/template/builder-spec.coffee
2011-12-27 16:16:35 -06:00

38 lines
1020 B
CoffeeScript

Builder = require 'template/builder'
fdescribe "Builder", ->
builder = null
beforeEach -> builder = new Builder
describe ".tag(name, args...)", ->
it "can generate simple tags", ->
builder.tag 'div'
expect(builder.toHtml()).toBe("<div></div>")
builder.reset()
builder.tag 'ol'
expect(builder.toHtml()).toBe("<ol></ol>")
it "can generate tags with content", ->
builder.tag 'ol', ->
builder.tag 'li'
builder.tag 'li'
expect(builder.toHtml()).toBe("<ol><li></li><li></li></ol>")
it "can generate tags with text", ->
builder.tag 'div', "hello"
expect(builder.toHtml()).toBe("<div>hello</div>")
builder.reset()
builder.tag 'div', 22
expect(builder.toHtml()).toBe("<div>22</div>")
it "can generate tags with attributes", ->
builder.tag 'div', id: 'foo', class: 'bar'
fragment = builder.toFragment()
expect(fragment.attr('id')).toBe('foo')
expect(fragment.attr('class')).toBe('bar')