diaspora/spec/javascripts/app/views/stream_faces_view_spec.js
danielgrippi b583a7a444 Put dennis's changes back in
Revert "Revert "refactoring backbone urls""

This reverts commit 838da1fd52.

Revert "revert 9b1d64bb76 as it is causing inf. scroll to break (stream model now has a post collection)"

This reverts commit 2a69c0ebd4.
2012-01-19 17:05:30 -08:00

50 lines
1.9 KiB
JavaScript

describe("app.views.StreamFaces", function(){
beforeEach(function(){
var rebeccaBlack = factory.author({name : "Rebecca Black", id : 1492})
this.post1 = factory.post({author : rebeccaBlack})
this.post2 = factory.post({author : factory.author({name : "John Stamos", id : 1987})})
this.post3 = factory.post({author : factory.author({name : "Michelle Tanner", id : 1986})})
this.post4 = factory.post({author : factory.author({name : "Barack Obama", id : 2000})})
this.post5 = factory.post({author : factory.author({name : "Obie-won Kenobie", id : 2020})})
this.post6 = factory.post({author : rebeccaBlack})
this.post7 = factory.post({author : rebeccaBlack})
app.stream = new app.models.Stream()
app.stream.add([this.post1, this.post2, this.post3, this.post4, this.post5, this.post6, this.post7]);
this.posts = app.stream.posts
this.view = new app.views.StreamFaces({collection : this.posts})
})
it("should take them unique", function(){
this.view.render()
expect(this.view.people.length).toBe(5)
})
it("findsPeople when the collection changes", function(){
this.posts.add(factory.post({author : factory.author({name : "Harriet Tubman"})}))
expect(this.view.people.length).toBe(6)
})
describe(".render", function(){
beforeEach(function(){
this.view.render()
})
it("appends the people's avatars", function(){
expect(this.view.$("img").length).toBe(5)
})
it("links to the people", function(){
expect(this.view.$("a").length).toBe(5)
})
it("rerenders when people are added, but caps to 15 people", function(){
var posts = _.map(_.range(20), function(){ return factory.post()})
this.posts.reset(posts) //add 20 posts silently to the collection
this.posts.add(factory.post) //trigger an update
expect(this.view.$("img").length).toBe(15)
})
})
})