'use strict';

var RootComponent = require('../lib/root-component.jsx'),

    React = require('react'),
    ReactTestUtils = require('react/lib/ReactTestUtils'),

    expect = require('chai').expect;

function randomInt(min, max) {
    return Math.floor(Math.random() * (max - min)) + min;
}

function generateDummyItems(number) {
    var items = [],
        index;

    for (index = 0; index < number; index += 1) {
        items.push({
            name: '' + randomInt(10, 50)
        });
    }

    return items;
}

describe('Root Component', function () {
    var rootElement;

    beforeEach(function () {
        rootElement = React.createElement(RootComponent, {
            users: []
        });
    });

    it('should be a unordered list', function () {
        var renderedRootElement = ReactTestUtils.renderIntoDocument(rootElement),
            renderedDOMNode = renderedRootElement.getDOMNode();

        expect(renderedDOMNode.tagName).to.equal('UL');
    });

    describe('when the list is rendered with a set of users', function () {
        var rootElementWithItems,
            renderedElementWithItems,
            listItems,
            expectedNumberOfItems,
            dummyUsers;

        beforeEach(function () {
            expectedNumberOfItems = randomInt(20, 30);
            dummyUsers = generateDummyItems(expectedNumberOfItems);

            rootElementWithItems = React.createElement(RootComponent, {
                users: dummyUsers
            });

            renderedElementWithItems = ReactTestUtils.renderIntoDocument(rootElementWithItems);
            listItems = ReactTestUtils.scryRenderedDOMComponentsWithTag(renderedElementWithItems, 'LI');
        });

        it('should render an LI for each of the items', function () {
            expect(listItems).to.have.length(expectedNumberOfItems);
        });

        it('should include the name of the user in each item', function () {
            listItems.forEach(function (listItemElement, index) {
                var listItemNode = listItemElement.getDOMNode(),
                    dummyUser = dummyUsers[index].name;

                expect(listItemNode.textContent).to.equal(dummyUser);
            });
        });
    });
});

@@ -869,16 +869,34 @@
 MNode = 
+React.findDOMNode(
 rendered
@@ -906,28 +906,16 @@
 tElement
-.getDOMNode(
 );%0A%0A    
@@ -2030,16 +2030,34 @@
 mNode = 
+React.findDOMNode(
 listItem
@@ -2067,20 +2067,8 @@
 ment
-.getDOMNode(
 ),%0A 

Replace `getDOMNode` with `React.findDOMNode`. Thanks to @dariocravero for pointing that out.