htmldiff
Version:
HTML Diffing in JavaScript (CoffeeScript)
31 lines (22 loc) • 916 B
text/coffeescript
describe 'html_to_tokens', ->
beforeEach ->
= (require '../src/htmldiff.coffee').html_to_tokens
it 'should be a function', ->
(expect ).is.a 'function'
describe 'when called with text', ->
beforeEach ->
= 'this is a test'
it 'should return 4', ->
(expect .length).to.equal 7
describe 'when called with html', ->
beforeEach ->
= '<p>this is a <strong>test</strong></p>'
it 'should return 11', ->
(expect .length).to.equal 11
it 'should identify contiguous whitespace as a single token', ->
(expect 'a b').to.eql ['a', ' ', 'b']
it 'should identify a single space as a single token', ->
(expect ' a b ').to.eql [' ', 'a', ' ', 'b', ' ']
it 'should identify self closing tags as tokens', ->
(expect '<p>hello</br>goodbye</p>')
.eql ['<p>', 'hello', '</br>', 'goodbye', '</p>']