Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81159 views
1
/**
2
* Copyright 2013-2014, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @emails react-core
10
*/
11
12
"use strict";
13
14
var SyntheticWheelEvent;
15
16
describe('SyntheticWheelEvent', function() {
17
var createEvent;
18
19
beforeEach(function() {
20
SyntheticWheelEvent = require('SyntheticWheelEvent');
21
22
createEvent = function(nativeEvent) {
23
return SyntheticWheelEvent.getPooled({}, '', nativeEvent);
24
};
25
});
26
27
it('should normalize properties from the Event interface', function() {
28
var target = document.createElement('div');
29
var syntheticEvent = createEvent({srcElement: target});
30
31
expect(syntheticEvent.target).toBe(target);
32
expect(syntheticEvent.type).toBe(undefined);
33
});
34
35
it('should normalize properties from the MouseEvent interface', function() {
36
expect(createEvent({which: 2, button: 1}).button).toBe(1);
37
});
38
39
it('should normalize properties from the WheelEvent interface', function() {
40
var standardEvent = createEvent({deltaX: 10, deltaY: -50});
41
expect(standardEvent.deltaX).toBe(10);
42
expect(standardEvent.deltaY).toBe(-50);
43
44
var webkitEvent = createEvent({wheelDeltaX: -10, wheelDeltaY: 50});
45
expect(webkitEvent.deltaX).toBe(10);
46
expect(webkitEvent.deltaY).toBe(-50);
47
});
48
49
it('should be able to `preventDefault` and `stopPropagation`', function() {
50
var nativeEvent = {};
51
var syntheticEvent = createEvent(nativeEvent);
52
53
expect(syntheticEvent.isDefaultPrevented()).toBe(false);
54
syntheticEvent.preventDefault();
55
expect(syntheticEvent.isDefaultPrevented()).toBe(true);
56
57
expect(syntheticEvent.isPropagationStopped()).toBe(false);
58
syntheticEvent.stopPropagation();
59
expect(syntheticEvent.isPropagationStopped()).toBe(true);
60
});
61
62
it('should be able to `persist`', function() {
63
var syntheticEvent = createEvent({});
64
65
expect(syntheticEvent.isPersistent()).toBe(false);
66
syntheticEvent.persist();
67
expect(syntheticEvent.isPersistent()).toBe(true);
68
});
69
70
});
71
72