react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / browser / ui / __tests__ / ReactMountDestruction-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 = require('React');1415describe('ReactMount', function() {16it("should destroy a react root upon request", function() {17var mainContainerDiv = document.createElement('div');18document.documentElement.appendChild(mainContainerDiv);1920var instanceOne = (21<div className="firstReactDiv">22</div>23);24var firstRootDiv = document.createElement('div');25mainContainerDiv.appendChild(firstRootDiv);26React.render(instanceOne, firstRootDiv);2728var instanceTwo = (29<div className="secondReactDiv">30</div>31);32var secondRootDiv = document.createElement('div');33mainContainerDiv.appendChild(secondRootDiv);34React.render(instanceTwo, secondRootDiv);3536// Test that two react roots are rendered in isolation37expect(firstRootDiv.firstChild.className).toBe('firstReactDiv');38expect(secondRootDiv.firstChild.className).toBe('secondReactDiv');3940// Test that after unmounting each, they are no longer in the document.41React.unmountComponentAtNode(firstRootDiv);42expect(firstRootDiv.firstChild).toBeNull();43React.unmountComponentAtNode(secondRootDiv);44expect(secondRootDiv.firstChild).toBeNull();45});46});474849