react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / core / __tests__ / ReactCompositeComponentDOMMinimalism-test.js
81155 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";1213// Requires14var React;15var ReactTestUtils;16var reactComponentExpect;1718// Test components19var LowerLevelComposite;20var MyCompositeComponent;2122var expectSingleChildlessDiv;2324/**25* Integration test, testing the combination of JSX with our unit of26* abstraction, `ReactCompositeComponent` does not ever add superfluous DOM27* nodes.28*/29describe('ReactCompositeComponentDOMMinimalism', function() {3031beforeEach(function() {32reactComponentExpect = require('reactComponentExpect');33React = require('React');34ReactTestUtils = require('ReactTestUtils');3536LowerLevelComposite = React.createClass({37render: function() {38return (39<div>40{this.props.children}41</div>42);43}44});4546MyCompositeComponent = React.createClass({47render: function() {48return (49<LowerLevelComposite>50{this.props.children}51</LowerLevelComposite>52);53}54});5556expectSingleChildlessDiv = function(instance) {57reactComponentExpect(instance)58.expectRenderedChild()59.toBeCompositeComponentWithType(LowerLevelComposite)60.expectRenderedChild()61.toBeDOMComponentWithTag('div')62.toBeDOMComponentWithNoChildren();63};64});6566it('should not render extra nodes for non-interpolated text', function() {67var instance = (68<MyCompositeComponent>69A string child70</MyCompositeComponent>71);72instance = ReactTestUtils.renderIntoDocument(instance);73expectSingleChildlessDiv(instance);74});7576it('should not render extra nodes for non-interpolated text', function() {77var instance = (78<MyCompositeComponent>79{'Interpolated String Child'}80</MyCompositeComponent>81);82instance = ReactTestUtils.renderIntoDocument(instance);83expectSingleChildlessDiv(instance);84});8586it('should not render extra nodes for non-interpolated text', function() {87var instance = (88<MyCompositeComponent>89<ul>90This text causes no children in ul, just innerHTML91</ul>92</MyCompositeComponent>93);94instance = ReactTestUtils.renderIntoDocument(instance);95reactComponentExpect(instance)96.expectRenderedChild()97.toBeCompositeComponentWithType(LowerLevelComposite)98.expectRenderedChild()99.toBeDOMComponentWithTag('div')100.toBeDOMComponentWithChildCount(1)101.expectRenderedChildAt(0)102.toBeDOMComponentWithTag('ul')103.toBeDOMComponentWithNoChildren();104});105106});107108109