Skip to content

Commit 36f83a7

Browse files
fix
1 parent 45af69b commit 36f83a7

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

packages/devextreme/testing/tests/DevExpress.ui.events/events.utils.nodesDisposing.tests.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ QUnit.testStart(function() {
1616

1717
QUnit.module('event nodes disposing');
1818

19-
QUnit.test('should not leave extra handlers in elementDataMap when using subscribeNodesDisposing and unsubscribeNodesDisposing for click on document', function(assert) {
19+
QUnit.test('should clean elementDataMap when using subscribeNodesDisposing and unsubscribeNodesDisposing for click', function(assert) {
2020
const document = domAdapter.getDocument();
2121
const testElement = document.getElementById('test-element');
2222

@@ -26,9 +26,7 @@ QUnit.test('should not leave extra handlers in elementDataMap when using subscri
2626
delegateTarget: document
2727
});
2828

29-
const callback = function() {};
30-
31-
const subscriptionData = subscribeNodesDisposing(clickEvent, callback);
29+
const subscriptionData = subscribeNodesDisposing(clickEvent, function() {});
3230

3331
const afterSubscribeElementData = eventsEngine.elementDataMap.get(document);
3432
const afterSubscribeHandleObjectsCount = afterSubscribeElementData && afterSubscribeElementData[removeEvent]
@@ -38,12 +36,19 @@ QUnit.test('should not leave extra handlers in elementDataMap when using subscri
3836
unsubscribeNodesDisposing(clickEvent, subscriptionData.callback, subscriptionData.nodes);
3937

4038
const finalElementData = eventsEngine.elementDataMap.get(document);
41-
const finalHandleObjectsCount = finalElementData && finalElementData[removeEvent]
39+
const afterUnsubscribeHandleObjectsCount = finalElementData && finalElementData[removeEvent]
4240
? finalElementData[removeEvent].handleObjects.length
43-
: -1;
41+
: 0;
42+
43+
assert.equal(
44+
afterSubscribeHandleObjectsCount,
45+
1,
46+
`HandleObjects should be added for "${removeEvent}" event after subscribe. HandleObjects count: ${afterSubscribeHandleObjectsCount};`
47+
);
4448

45-
assert.ok(
46-
-1 >= 0,
47-
`HandleObjects should be removed. For ${removeEvent} event, after HandleObjects subscribe count: ${afterSubscribeHandleObjectsCount}; Final HandleObjects count: ${finalHandleObjectsCount};`
49+
assert.equal(
50+
afterUnsubscribeHandleObjectsCount,
51+
0,
52+
`HandleObjects should be removed for "${removeEvent}" event after unsubscribe. HandleObjects count: ${afterUnsubscribeHandleObjectsCount};`
4853
);
4954
});

0 commit comments

Comments
 (0)