react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / browser / syntheticEvents / __tests__ / SyntheticWheelEvent-test.js
81159 views/**1* Copyright 2013-2014, Facebook, Inc.2* All rights reserved.3*4* This source code is licensed under the BSD-style license found in the5* LICENSE file in the root directory of this source tree. An additional grant6* of patent rights can be found in the PATENTS file in the same directory.7*8* @emails react-core9*/1011"use strict";1213var SyntheticWheelEvent;1415describe('SyntheticWheelEvent', function() {16var createEvent;1718beforeEach(function() {19SyntheticWheelEvent = require('SyntheticWheelEvent');2021createEvent = function(nativeEvent) {22return SyntheticWheelEvent.getPooled({}, '', nativeEvent);23};24});2526it('should normalize properties from the Event interface', function() {27var target = document.createElement('div');28var syntheticEvent = createEvent({srcElement: target});2930expect(syntheticEvent.target).toBe(target);31expect(syntheticEvent.type).toBe(undefined);32});3334it('should normalize properties from the MouseEvent interface', function() {35expect(createEvent({which: 2, button: 1}).button).toBe(1);36});3738it('should normalize properties from the WheelEvent interface', function() {39var standardEvent = createEvent({deltaX: 10, deltaY: -50});40expect(standardEvent.deltaX).toBe(10);41expect(standardEvent.deltaY).toBe(-50);4243var webkitEvent = createEvent({wheelDeltaX: -10, wheelDeltaY: 50});44expect(webkitEvent.deltaX).toBe(10);45expect(webkitEvent.deltaY).toBe(-50);46});4748it('should be able to `preventDefault` and `stopPropagation`', function() {49var nativeEvent = {};50var syntheticEvent = createEvent(nativeEvent);5152expect(syntheticEvent.isDefaultPrevented()).toBe(false);53syntheticEvent.preventDefault();54expect(syntheticEvent.isDefaultPrevented()).toBe(true);5556expect(syntheticEvent.isPropagationStopped()).toBe(false);57syntheticEvent.stopPropagation();58expect(syntheticEvent.isPropagationStopped()).toBe(true);59});6061it('should be able to `persist`', function() {62var syntheticEvent = createEvent({});6364expect(syntheticEvent.isPersistent()).toBe(false);65syntheticEvent.persist();66expect(syntheticEvent.isPersistent()).toBe(true);67});6869});707172