Increase mobile reshare counter after reshare

This commit is contained in:
Steffen van Bergerem 2017-08-09 23:53:16 +02:00
parent 18256f3709
commit bc0088eb47
No known key found for this signature in database
GPG key ID: 315C9787D548DC6B
2 changed files with 17 additions and 2 deletions

View file

@ -103,6 +103,10 @@
},
success: function() {
Diaspora.Mobile.PostActions.toggleActive(link);
var reshareCounter = $(evt.target).closest(".stream-element").find(".reshare-count");
if (reshareCounter) {
reshareCounter.text(parseInt(reshareCounter.text(), 10) + 1);
}
},
error: function(response) {
Diaspora.Mobile.Alert.handleAjaxError(response);

View file

@ -88,7 +88,7 @@ describe("Diaspora.Mobile.PostActions", function(){
spec.loadFixture("aspects_index_mobile_public_post");
Diaspora.Mobile.PostActions.initialize();
this.link = $(".stream .like-action").first();
this.likeCounter = this.link.closest(".stream-element").find(".like-count");
this.likeCounter = this.link.find(".like-count");
});
it("always calls showLoader before sending request", function(){
@ -143,7 +143,7 @@ describe("Diaspora.Mobile.PostActions", function(){
spec.loadFixture("aspects_index_mobile_public_post");
Diaspora.Mobile.PostActions.initialize();
this.link = $(".stream .like-action").first();
this.likeCounter = this.link.closest(".stream-element").find(".like-count");
this.likeCounter = this.link.find(".like-count");
Diaspora.Mobile.PostActions.like(this.likeCounter, this.link);
jasmine.Ajax.requests.mostRecent().respondWith({status: 201, responseText: "{\"id\": \"18\"}"});
});
@ -238,6 +238,17 @@ describe("Diaspora.Mobile.PostActions", function(){
expect(Diaspora.Mobile.PostActions.toggleActive).toHaveBeenCalledWith(this.reshareLink);
});
it("increases the reshare count on success", function() {
spyOn(Diaspora.Mobile.PostActions, "toggleActive");
var reshareCounter = this.reshareLink.find(".reshare-count");
reshareCounter.text("8");
this.reshareLink.click();
jasmine.Ajax.requests.mostRecent().respondWith({status: 201, responseText: "{}"});
expect(Diaspora.Mobile.PostActions.toggleActive).toHaveBeenCalledWith(this.reshareLink);
expect(reshareCounter.text()).toBe("9");
});
it("lets Diaspora.Mobile.Alert handle AJAX errors", function() {
spyOn(Diaspora.Mobile.Alert, "handleAjaxError");
this.reshareLink.click();