process.mixin(require('express/collection')) process.mixin(require('express/element-collection')) describe 'Express' describe 'ElementCollection' describe '$("markup string")' it 'should return a ElementCollection' $('
foo
').should.be_an_instance_of Collection $('foo
').should.be_an_instance_of ElementCollection end it 'should wrap with .. when not present' $('foo
').at(0).name().should.eql 'html' end it 'should not wrap with when already present' $('').at(0).name().should.eql 'html' end end describe '#name()' it 'should return the first elements name' $('').name().should.eql 'html' end end describe '#xpath()' it 'should find children matching the given xpath' $('Foo
Bar
foobar
').children().length().should.eql 1 $('foobar
').xpath('descendant-or-self::p').children().length().should.eql 2 end end describe '#parents()' it 'should return parents' $('foo bar
').text().should.eql 'foo bar' end end describe '#next()' it 'should return the next element' $('foobar
').xpath('descendant-or-self::em').next().text().should.eql 'bar' end end describe '#prev()' it 'should return the previous element' $('foobar
').xpath('descendant-or-self::p').prev().text().should.eql 'foo' end end end end