Don't overwrite app.stream properties in tests
These cases of modifying app.stream can cause other specs to fail, depending on test order. Here we either don't modify them if the tests still pass without manually stubbing `addNow`, or we cache and restore the properties we need to test.
This commit is contained in:
parent
f4234fa3a0
commit
56ef83fa8a
2 changed files with 13 additions and 4 deletions
|
|
@ -122,9 +122,11 @@ describe("app.models.Post.Interactions", function(){
|
|||
});
|
||||
|
||||
it("adds the reshare to the default, activity and aspects stream", function() {
|
||||
app.stream = { addNow: $.noop };
|
||||
app.stream = new app.models.Stream(_, { basePath: "/aspects/all" });
|
||||
|
||||
spyOn(app.stream, "addNow");
|
||||
var self = this;
|
||||
|
||||
["/stream", "/activity", "/aspects"].forEach(function(path) {
|
||||
app.stream.basePath = function() { return path; };
|
||||
self.interactions.reshare();
|
||||
|
|
@ -132,10 +134,13 @@ describe("app.models.Post.Interactions", function(){
|
|||
|
||||
expect(app.stream.addNow).toHaveBeenCalledWith({id: 1});
|
||||
});
|
||||
|
||||
new app.models.Stream(_, { basePath: "/aspects/all" });
|
||||
});
|
||||
|
||||
it("doesn't add the reshare to any other stream", function() {
|
||||
app.stream = { addNow: $.noop };
|
||||
app.stream = new app.models.Stream(_, { basePath: "/aspects/all" });
|
||||
|
||||
spyOn(app.stream, "addNow");
|
||||
var self = this;
|
||||
["/followed_tags", "/mentions/", "/tag/diaspora", "/people/guid/stream"].forEach(function(path) {
|
||||
|
|
@ -144,6 +149,8 @@ describe("app.models.Post.Interactions", function(){
|
|||
jasmine.Ajax.requests.mostRecent().respondWith(ajaxSuccess);
|
||||
expect(app.stream.addNow).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
new app.models.Stream(_, { basePath: "/aspects/all" });
|
||||
});
|
||||
|
||||
it("sets the participation flag for the post", function() {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ describe("app.views.Publisher", function() {
|
|||
|
||||
describe("createStatusMessage", function(){
|
||||
it("doesn't add the status message to the stream", function() {
|
||||
app.stream = { addNow: $.noop };
|
||||
app.stream = new app.models.Stream();
|
||||
|
||||
spyOn(app.stream, "addNow");
|
||||
this.view.createStatusMessage($.Event());
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, responseText: "{\"id\": 1}" });
|
||||
|
|
@ -198,7 +199,8 @@ describe("app.views.Publisher", function() {
|
|||
|
||||
describe("createStatusMessage", function(){
|
||||
it("adds the status message to the stream", function() {
|
||||
app.stream = { addNow: $.noop };
|
||||
new app.models.Stream();
|
||||
|
||||
spyOn(app.stream, "addNow");
|
||||
this.view.createStatusMessage($.Event());
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, responseText: "{\"id\": 1}" });
|
||||
|
|
|
|||
Loading…
Reference in a new issue