Newer
Older
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
describe("app.models.Stream", function() {
beforeEach(function(){
this.stream = new app.models.Stream(),
this.expectedPath = document.location.pathname;
})
describe(".fetch", function() {
var postFetch
beforeEach(function(){
postFetch = new $.Deferred()
spyOn(this.stream.posts, "fetch").andCallFake(function(){
return postFetch
})
})
it("it fetches posts from the window's url, and ads them to tthe collection", function() {
this.stream.fetch()
expect(this.stream.posts.fetch).toHaveBeenCalledWith({ add : true, url : this.expectedPath});
});
it("returns the json path with max_time if the collection has models", function() {
var post = new app.models.Post();
spyOn(post, "createdAt").andReturn(1234);
this.stream.add(post);
this.stream.fetch()
expect(this.stream.posts.fetch).toHaveBeenCalledWith({ add : true, url : this.expectedPath + "?max_time=1234"});
});
it("triggers fetched on the stream when it is fetched", function(){
var fetchedSpy = jasmine.createSpy()
this.stream.bind('fetched', fetchedSpy)
this.stream.fetch()
postFetch.resolve()
expect(fetchedSpy).toHaveBeenCalled()
})
});
});