Skip to content

Commit

Permalink
reorganize split and merge tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Feb 9, 2015
1 parent cc38db3 commit 60d1eac
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions test/unit/lib/dom.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -343,36 +343,40 @@ describe('DOM', ->
)
)

describe('split + merge', ->
describe('merge', ->
beforeEach( ->
@container = $('#test-container').html('').get(0)
)

describe('merge', ->
it('merge nodes', ->
@container.innerHTML = '<ul><li>One</li></ul><ul><li>Two</li></ul>'
dom(@container.firstChild).merge(@container.lastChild)
expect(@container).toEqualHTML('<ul><li>One</li><li>Two</li></ul>')
)
it('nodes', ->
@container.innerHTML = '<ul><li>One</li></ul><ul><li>Two</li></ul>'
dom(@container.firstChild).merge(@container.lastChild)
expect(@container).toEqualHTML('<ul><li>One</li><li>Two</li></ul>')
)

it('merge and normalize', ->
@container.innerHTML = '<span>One</span><span>Two</span>'
expect(@container.childNodes.length).toEqual(2)
dom(@container.firstChild).merge(@container.lastChild)
expect(@container).toEqualHTML('<span>OneTwo</span>')
expect(@container.childNodes.length).toEqual(1)
expect(@container.firstChild.childNodes.length).toEqual(1)
)
it('normalize', ->
@container.innerHTML = '<span>One</span><span>Two</span>'
expect(@container.childNodes.length).toEqual(2)
dom(@container.firstChild).merge(@container.lastChild)
expect(@container).toEqualHTML('<span>OneTwo</span>')
expect(@container.childNodes.length).toEqual(1)
expect(@container.firstChild.childNodes.length).toEqual(1)
)

it('merge text nodes', ->
@container.innerHTML = ''
@container.appendChild(document.createTextNode('One'))
@container.appendChild(document.createTextNode('Two'))
expect(@container.childNodes.length).toEqual(2)
dom(@container.firstChild).merge(@container.lastChild)
expect(@container).toEqualHTML('OneTwo')
expect(@container.childNodes.length).toEqual(1)
)
it('text nodes', ->
@container.innerHTML = ''
@container.appendChild(document.createTextNode('One'))
@container.appendChild(document.createTextNode('Two'))
expect(@container.childNodes.length).toEqual(2)
dom(@container.firstChild).merge(@container.lastChild)
expect(@container).toEqualHTML('OneTwo')
expect(@container.childNodes.length).toEqual(1)
)
)

describe('split', ->
beforeEach( ->
@container = $('#test-container').html('').get(0)
)

describe('splitBefore()', ->
Expand Down

0 comments on commit 60d1eac

Please sign in to comment.