File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed
force-app/test/default/staticresources Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,42 @@ describe("Redux Tests", function() {
198198 done.fail(e);
199199 });
200200 });
201+
202+ it('unsubscribes when destroyed', function(done) {
203+ var renderInto = document.getElementById("renderTestComponents");
204+ $T.createComponent("c:TestReduxContainer", {}, renderInto)
205+ .then(function(component) {
206+
207+ var redux = component.find("store");
208+
209+ var toggle = false;
210+ function toggleReducer(state, action) {
211+ toggle = !toggle;
212+ if(toggle) {
213+ return "Toggle is True";
214+ } else {
215+ return "Toggle is False";
216+ }
217+ }
218+
219+ redux.createStore("toggle", toggleReducer);
220+
221+ var mapStateToAttributes = {
222+ "v.message": "toggle"
223+ };
224+
225+ redux.connect(mapStateToAttributes, component);
226+ expect(component.get("v.message")).toBe("Toggle is True");
227+ component.dispatch({type: "INCREMENT"});
228+ expect(component.get("v.message")).toBe("Toggle is False");
229+ component.destroy();
230+ component.dispatch({type: "INCREMENT"});
231+ expect(component.get("v.message")).toBe("Toggle is True");
232+ done();
233+ }).catch(function(e) {
234+ done.fail(e);
235+ });
236+ });
201237 });
202238
203239 describe('Test Queueing', function() {
Original file line number Diff line number Diff line change 114114 while (cmpsToCleanup.length) {
115115 var globalId = cmpsToCleanup.shift();
116116 var cmp = $A.getComponent(globalId);
117- cmp.destroy();
117+ if(cmp && cmp.isValid()) {
118+ cmp.destroy();
119+ }
118120 }
119121 }
120122
You can’t perform that action at this time.
0 commit comments