import '../client_helper';

import UserNamePrompter from '../../client/username-prompter';

describe('UserNamePrompter', () => {
  it('is visible if the username is null');

  it('is hidden if the username is present');

  describe('when the button is clicked', () => {
    it('calls the signin call back with the username');
  });

  describe('on hide', () => {
    it('stays open');
  });
});

import '../client_helper';
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import { Modal } from 'react-bootstrap';

import UserNamePrompter from '../../client/username-prompter';

describe('UserNamePrompter', () => {
  const onEnter = jasmine.createSpy('onEnter');
  function createUserNamePrompter(props = {}) {
    return ReactTestUtils.renderIntoDocument(<UserNamePrompter
      user={props.user || null} onEnter={props.onEnter || onEnter} />);
  }
  it('is visible if the username is undefined', () => {
    const component = createUserNamePrompter({user: undefined});
    // TODO test via class name
    const modal = ReactTestUtils.findRenderedComponentWithType(component, Modal);
    expect(modal.props.show).toBe(true);
  });

  it('is hidden if the username is present', () => {
    const component = createUserNamePrompter({user: 'jim'});
    const modal = ReactTestUtils.findRenderedComponentWithType(component, Modal);
    expect(modal.props.show).toBe(false);
  });

  describe('when the button is clicked', () => {
    it('calls the signin call back with the username');
  });

  describe('on hide', () => {
    it('stays open');
  });
});

Test showing/hiding a username modal prompt
Test showing/hiding a username modal prompt

Currently this is using `ReactTestUtils.findRenderedComponentWithType` and then introspecting the `show` prop on the modal to determine if it's visible. I'd preferably like to use bootstrap classes, but `ReactTestUtils.findRenderedDOMComponentWithClass` doesn't work because the modal is using a [portal](https://github.com/tajo/react-portal) to render the modal outside of the render tree. I'd like to come back to this at some point and see if I can rewrite the tests to avoid introspecting on Modal props.
