This repository has been archived by the owner on Oct 19, 2018. It is now read-only.
/
listview.coffee
58 lines (48 loc) · 1.81 KB
/
listview.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
ListView = infinity.ListView
ELEMENT_SELECTOR = '#test'
describe 'ListView', ->
$el = $ ELEMENT_SELECTOR
lv = null
beforeEach ->
lv = new ListView $el
afterEach ->
lv.remove()
it 'should be able to be added and removed from an element', ->
lv.remove()
expect($(ELEMENT_SELECTOR).length).to.be(1)
expect($(ELEMENT_SELECTOR).children().length).to.be(0)
it 'should be initialized with no height', ->
expect(lv.height).to.be(0)
expect($el.height()).to.be(0)
it 'should find things appended to it with a CSS selector', ->
$content = $ '<div class=test></div>'
lv.append $content
find = lv.find '.test'
expect(find[0].$el).to.be($content)
it 'should find things prepended to it with a CSS selector', ->
$content = $ '<div class=test></div>'
lv.prepend $content
find = lv.find '.test'
expect(find[0].$el).to.be($content)
it 'should find things appended to it given a jQuery element', ->
$content = $ '<div></div>'
lv.append($content)
find = lv.find $content
expect(find[0].$el).to.be($content)
it 'should find things prepended to it given a jQuery element', ->
$content = $ '<div></div>'
lv.prepend($content)
find = lv.find $content
expect(find[0].$el).to.be($content)
it 'should find things appended to it given a different jQuery element wrapping the same DOM node', ->
$content = $ '<div id=hello></div>'
lv.append($content)
$contentFromJQ = $('#hello')
find = lv.find $contentFromJQ
expect(find[0].$el.is($content)).to.be.ok()
it 'should find things prepended to it given a different jQuery element wrapping the same DOM node', ->
$content = $ '<div id=hello></div>'
lv.prepend($content)
$contentFromJQ = $('#hello')
find = lv.find $contentFromJQ
expect(find[0].$el.is($content)).to.be.ok()