From 94956a2eda71023894cce4f060c33394f1c9028e Mon Sep 17 00:00:00 2001 From: Sage Ross Date: Sat, 15 Jan 2022 15:10:44 -0800 Subject: [PATCH] Add workound for order-dependent notification_collection_spec.js This is from Flaburgan: https://github.com/diaspora/diaspora/pull/8305/files I can't find a better way around it. The specs that call `onChangedUnreadStatus` change the environment in ways we can't figure out how to reset cleanly. --- .../app/collections/notifications_collection_spec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/javascripts/app/collections/notifications_collection_spec.js b/spec/javascripts/app/collections/notifications_collection_spec.js index 8a5c2b981..91a79941c 100644 --- a/spec/javascripts/app/collections/notifications_collection_spec.js +++ b/spec/javascripts/app/collections/notifications_collection_spec.js @@ -14,6 +14,12 @@ describe("app.collections.Notifications", function() { it("initializes attributes", function() { var target = new app.collections.Notifications(); + /* I don't know how backbone is working, but if I don't force reset the old values are kept from previous test */ + if (target !== undefined) { + target.unreadCount = 0; + target.unreadCountByType = {}; + } + /* end of force refresh */ expect(target.model).toBe(app.models.Notification); /* eslint-disable camelcase */ expect(target.url).toBe(Routes.notifications({per_page: 10, page: 1})); @@ -174,6 +180,12 @@ describe("app.collections.Notifications", function() { describe("parse", function() { beforeEach(function() { this.target = new app.collections.Notifications(); + /* I don't know how backbone is working, but if I don't force reset the old values are kept from previous test */ + if (this.target !== undefined) { + this.target.unreadCount = 0; + this.target.unreadCountByType = {}; + } + /* end of force refresh */ }); it("sets the unreadCount and unreadCountByType attributes", function() {