Skip to content

Commit a33d1e7

Browse files
Alex VinoberAlex Vinober
Alex Vinober
authored and
Alex Vinober
committed
Test updated: countCoverSlip moved to upper level, one more check, that handler won't being called on right click
1 parent 6366615 commit a33d1e7

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

test/jasmine/tests/dragelement_test.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ describe('dragElement', function() {
3030

3131
afterEach(destroyGraphDiv);
3232

33+
function countCoverSlip() {
34+
return d3.selectAll('.dragcover').size();
35+
}
36+
3337
it('should init drag element', function() {
3438
var options = { element: this.element, gd: this.gd };
3539
dragElement.init(options);
@@ -103,10 +107,6 @@ describe('dragElement', function() {
103107
});
104108

105109
it('should add a cover slip div to the DOM', function() {
106-
function countCoverSlip() {
107-
return d3.selectAll('.dragcover').size();
108-
}
109-
110110
var options = { element: this.element, gd: this.gd };
111111
dragElement.init(options);
112112

@@ -123,15 +123,21 @@ describe('dragElement', function() {
123123
});
124124

125125
it('should not add a cover slip div to the DOM when right click', function() {
126-
function countCoverSlip() {
127-
return d3.selectAll('.dragcover').size();
128-
}
129-
130126
var options = { element: this.element, gd: this.gd };
131127
dragElement.init(options);
132128

129+
var mockObj = {
130+
handleClick: function() {}
131+
};
132+
spyOn(mockObj, 'handleClick');
133+
134+
this.element.onclick = mockObj.handleClick;
135+
133136
mouseEvent('mousedown', this.x, this.y, { buttons: 2 });
134137
expect(countCoverSlip()).toEqual(0);
138+
139+
mouseEvent('mouseup', this.x, this.y);
140+
expect(mockObj.handleClick).not.toHaveBeenCalled();
135141
});
136142

137143
it('should fire off click event when down/up without dragging', function() {

0 commit comments

Comments
 (0)