<commit_before>var React = require('react');
var ReactTestUtils = require('react-addons-test-utils');

var RenderComponent = require('support/RenderComponent.js');
var Mocker = require('support/ComponentMocker.js');

var Workspace = require('project/components/Workspace.js');
var PairingBoardMock = Mocker("PairingBoard");
var PersonListMock = Mocker("PersonList");
var ModalMock = Mocker("Modal");
var NameFormMock = Mocker("NameForm");
Workspace.__set__('PairingBoard', PairingBoardMock);
Workspace.__set__('PersonList', PersonListMock);
Workspace.__set__('Modal', ModalMock);
Workspace.__set__('NameForm', NameFormMock);

describe('Workspace', function() {
    var props;
    var workspace;
    var newPersonModal;
    var newPersonForm;
    var newPairingBoardModal;
    var newPairingBoardForm;
    beforeEach(function() {
        props  = {
            projectId: 77,
            settings: {
                isNewPersonModalOpen: false,
                isNewPairingBoardModalOpen: true,
                errorType: 406
            },
            people: [
                {name:"<NAME>"},
                {name:"Sully"}
            ],
            pairingBoards: [
                {
                    name: "PairingBoard1",
                    people: [
                        {
                            name: "George"
                        }
                    ]
                },
                {
                    name: "Ghost",
                    people: [
                        {
                            name: "Coast2Coast"
                        }
                    ]
                }
            ],

            createPerson: jasmine.createSpy('createPersonSpy'),
            createPairingBoard: jasmine.createSpy('createPairingBoardSpy'),
            setNewPersonModalOpen: jasmine.createSpy('setNewPersonModalOpenSpy'),
            setNewPairingBoardModalOpen: jasmine.createSpy('setNewPairingBoardModalOpenSpy'),
            setErrorType: jasmine.createSpy('setErrorTypeSpy'),

            deletePairingBoard: function(){},
            renamePairingBoard: function(){}
        };

        workspace = RenderComponent(Workspace, <Workspace {...props} />);

        var Modals = ReactTestUtils.scryRenderedComponentsWithType(workspace, ModalMock);
        newPersonModal = Modals[0];
        newPairingBoardModal = Modals[1];

        newPersonForm = ReactTestUtils.findRenderedComponentWithType(newPersonModal, NameFormMock);
        newPairingBoardForm = ReactTestUtils.findRenderedComponentWithType(newPairingBoardModal, NameFormMock);
    });

    it('renders all of the pairingBoards in the project', function() {
        var pairingBoards = ReactTestUtils.scryRenderedComponentsWithType(workspace, PairingBoardMock);
        expect(pairingBoards.length).toBe(2, 'Not enough pairingBoards');

        expect(pairingBoards[0].props.name).toBe("PairingBoard1");
        expect(pairingBoards[0].props.people).toEqual([{name:"George"}]);
        expect(pairingBoards[0].props.index).toBe(0);
        expect(pairingBoards[0].props.deletePairingBoard).toBe(props.deletePairingBoard);
        expect(pairingBoards[0].props.renamePairingBoard).toBe(props.renamePairingBoard);

        expect(pairingBoards[1].props.name).toBe("Ghost");
        expect(pairingBoards[1].props.people).toEqual([{name:"Coast2Coast"}]);
        expect(pairingBoards[1].props.index).toBe(1);
        expect(pairingBoards[1].props.deletePairingBoard).toBe(props.deletePairingBoard);
        expect(pairingBoards[1].props.renamePairingBoard).toBe(props.renamePairingBoard);
    });

    it('renders the list of people in the project', function() {
        var people = ReactTestUtils.findRenderedComponentWithType(workspace, PersonListMock);
        expect(people).toBeDefined('No list of people');
        expect(people.props.people).toBe(props.people);
        expect(people.props.index).toBe(-1);
    });

    describe('newPersonModal', function() {
        it('has a configured newPersonModal component as a child', function() {
            expect(newPersonModal.props.isOpen).toBe(props.settings.isNewPersonModalOpen);
            expect(newPersonModal.props.onRequestClose).toBe(workspace.closeNewPersonModal);
        });

        it('has a configured new person form in a modal', function() {
            expect(newPersonForm.props.formTitle).toBe("Add Parrit Teammate");
            expect(newPersonForm.props.confirmFunction).toBe(workspace.createPersonWithName);
            expect(newPersonForm.props.cancelFunction).toBe(workspace.closeNewPersonModal);
        });

        it('passes in the correct error message if errorType is set', function() {
            expect(newPersonForm.props.errorMessage).toBe('Hey! This name is too long... 10 characters max.');<commit_msg>Fix test to match actual max character length for name<commit_after>var React = require('react');
var ReactTestUtils = require('react-addons-test-utils');

var RenderComponent = require('support/RenderComponent.js');
var Mocker = require('support/ComponentMocker.js');

var Workspace = require('project/components/Workspace.js');
var PairingBoardMock = Mocker("PairingBoard");
var PersonListMock = Mocker("PersonList");
var ModalMock = Mocker("Modal");
var NameFormMock = Mocker("NameForm");
Workspace.__set__('PairingBoard', PairingBoardMock);
Workspace.__set__('PersonList', PersonListMock);
Workspace.__set__('Modal', ModalMock);
Workspace.__set__('NameForm', NameFormMock);

describe('Workspace', function() {
    var props;
    var workspace;
    var newPersonModal;
    var newPersonForm;
    var newPairingBoardModal;
    var newPairingBoardForm;
    beforeEach(function() {
        props  = {
            projectId: 77,
            settings: {
                isNewPersonModalOpen: false,
                isNewPairingBoardModalOpen: true,
                errorType: 406
            },
            people: [
                {name:"<NAME>"},
                {name:"Sully"}
            ],
            pairingBoards: [
                {
                    name: "PairingBoard1",
                    people: [
                        {
                            name: "George"
                        }
                    ]
                },
                {
                    name: "Ghost",
                    people: [
                        {
                            name: "Coast2Coast"
                        }
                    ]
                }
            ],

            createPerson: jasmine.createSpy('createPersonSpy'),
            createPairingBoard: jasmine.createSpy('createPairingBoardSpy'),
            setNewPersonModalOpen: jasmine.createSpy('setNewPersonModalOpenSpy'),
            setNewPairingBoardModalOpen: jasmine.createSpy('setNewPairingBoardModalOpenSpy'),
            setErrorType: jasmine.createSpy('setErrorTypeSpy'),

            deletePairingBoard: function(){},
            renamePairingBoard: function(){}
        };

        workspace = RenderComponent(Workspace, <Workspace {...props} />);

        var Modals = ReactTestUtils.scryRenderedComponentsWithType(workspace, ModalMock);
        newPersonModal = Modals[0];
        newPairingBoardModal = Modals[1];

        newPersonForm = ReactTestUtils.findRenderedComponentWithType(newPersonModal, NameFormMock);
        newPairingBoardForm = ReactTestUtils.findRenderedComponentWithType(newPairingBoardModal, NameFormMock);
    });

    it('renders all of the pairingBoards in the project', function() {
        var pairingBoards = ReactTestUtils.scryRenderedComponentsWithType(workspace, PairingBoardMock);
        expect(pairingBoards.length).toBe(2, 'Not enough pairingBoards');

        expect(pairingBoards[0].props.name).toBe("PairingBoard1");
        expect(pairingBoards[0].props.people).toEqual([{name:"George"}]);
        expect(pairingBoards[0].props.index).toBe(0);
        expect(pairingBoards[0].props.deletePairingBoard).toBe(props.deletePairingBoard);
        expect(pairingBoards[0].props.renamePairingBoard).toBe(props.renamePairingBoard);

        expect(pairingBoards[1].props.name).toBe("Ghost");
        expect(pairingBoards[1].props.people).toEqual([{name:"Coast2Coast"}]);
        expect(pairingBoards[1].props.index).toBe(1);
        expect(pairingBoards[1].props.deletePairingBoard).toBe(props.deletePairingBoard);
        expect(pairingBoards[1].props.renamePairingBoard).toBe(props.renamePairingBoard);
    });

    it('renders the list of people in the project', function() {
        var people = ReactTestUtils.findRenderedComponentWithType(workspace, PersonListMock);
        expect(people).toBeDefined('No list of people');
        expect(people.props.people).toBe(props.people);
        expect(people.props.index).toBe(-1);
    });

    describe('newPersonModal', function() {
        it('has a configured newPersonModal component as a child', function() {
            expect(newPersonModal.props.isOpen).toBe(props.settings.isNewPersonModalOpen);
            expect(newPersonModal.props.onRequestClose).toBe(workspace.closeNewPersonModal);
        });

        it('has a configured new person form in a modal', function() {
            expect(newPersonForm.props.formTitle).toBe("Add Parrit Teammate");
            expect(newPersonForm.props.confirmFunction).toBe(workspace.createPersonWithName);
            expect(newPersonForm.props.cancelFunction).toBe(workspace.closeNewPersonModal);
        });

        it('passes in the correct error message if errorType is set', function() {
            expect(newPersonForm.props.errorMessage).toBe('Hey! This name is too long... 100 characters max.');
{'fraction_non_alphanumeric': 0.1144578313253012, 'fraction_numerical': 0.005712505193186539, 'mean_word_length': 2.669588414634146, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6606267', 'n_tokens_mistral': 2653, 'n_tokens_neox': 2583, 'n_words': 408}