react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / addons / transitions / __tests__ / ReactTransitionChildMapping-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 React;14var ReactTransitionChildMapping;1516describe('ReactTransitionChildMapping', function() {17beforeEach(function() {18React = require('React');19ReactTransitionChildMapping = require('ReactTransitionChildMapping');20});2122it('should support getChildMapping', function() {23var oneone = <div key="oneone" />;24var onetwo = <div key="onetwo" />;25var one = <div key="one">{oneone}{onetwo}</div>;26var two = <div key="two" />;27var component = <div>{one}{two}</div>;28expect(29ReactTransitionChildMapping.getChildMapping(component.props.children)30).toEqual({31'.$one': one,32'.$two': two33});34});3536it('should support mergeChildMappings for adding keys', function() {37var prev = {38one: true,39two: true40};41var next = {42one: true,43two: true,44three: true45};46expect(ReactTransitionChildMapping.mergeChildMappings(prev, next)).toEqual({47one: true,48two: true,49three: true50});51});5253it('should support mergeChildMappings for removing keys', function() {54var prev = {55one: true,56two: true,57three: true58};59var next = {60one: true,61two: true62};63expect(ReactTransitionChildMapping.mergeChildMappings(prev, next)).toEqual({64one: true,65two: true,66three: true67});68});6970it('should support mergeChildMappings for adding and removing', function() {71var prev = {72one: true,73two: true,74three: true75};76var next = {77one: true,78two: true,79four: true80};81expect(ReactTransitionChildMapping.mergeChildMappings(prev, next)).toEqual({82one: true,83two: true,84three: true,85four: true86});87});8889it('should reconcile overlapping insertions and deletions', function() {90var prev = {91one: true,92two: true,93four: true,94five: true95};96var next = {97one: true,98two: true,99three: true,100five: true101};102expect(ReactTransitionChildMapping.mergeChildMappings(prev, next)).toEqual({103one: true,104two: true,105three: true,106four: true,107five: true108});109});110111it('should support mergeChildMappings with undefined input', function() {112var prev = {113one: true,114two: true115};116117var next = undefined;118119expect(ReactTransitionChildMapping.mergeChildMappings(prev, next)).toEqual({120one: true,121two: true122});123124prev = undefined;125126next = {127three: true,128four: true129};130131expect(ReactTransitionChildMapping.mergeChildMappings(prev, next)).toEqual({132three: true,133four: true134});135});136});137138139