mirror of
https://github.com/atom/atom.git
synced 2026-02-11 07:05:11 -05:00
42 lines
1.1 KiB
CoffeeScript
42 lines
1.1 KiB
CoffeeScript
Builder = require 'template/builder'
|
|
|
|
describe "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'
|
|
|
|
it "can generate self-closing tags", ->
|
|
builder.tag 'br', id: 'foo'
|
|
expect(builder.toHtml()).toBe '<br id="foo">'
|
|
|