describeWithDOM('components', () => { describe('LoginForm', () => { it('should call login with form data', () => { const component = mount(<LoginForm {...props} />); const inputs = component.find('input'); changeInputValue(inputs.at(0), 'login'); changeInputValue(inputs.at(1), 'password'); component.find('form').simulate('submit'); expect(login).toHaveBeenCalledWith('login', 'password'); }) }); });
it('should render 1 ActiveProjectsTable with specific props', () => { const { component } = renderComponent({ activeProjects: ACTIVE_PROJECTS }); const activeProjectsTable = component.find(ActiveProjectsTable).at(0); expect(activeProjectsTable.props().projects).to.equal(ACTIVE_PROJECTS); expect(activeProjectsTable.props().selectedProjectId).to.equal(null); expect(activeProjectsTable.props().onSelectProject).to.be.a('function'); });
test('Entries cleared', () => { const output = mount(<WordsPanel/>); output.find('[type="button"]').at(clearButtonIndex).simulate('click'); const actions = getDispatchArguments(); const expectedActions = [ clearEntries(1), setOutput('') ]; expect(actions.sort(sorter)).toEqual(expectedActions.sort(sorter)); });
it ('create new recipe with: ingredient, recipe name', () => { const {componentWrapper, actions} = setup() const recipeName = 'name 1', ingredients = 'in1,in2' componentWrapper.find(FormControl).at(0).simulate('change', {target:{value: recipeName}}) componentWrapper.find(FormControl).at(1).simulate('change', {target:{value: ingredients}}) componentWrapper.find('form').simulate('submit') const args0 = actions.onSave.mock.calls[0][0]; expect(args0.recipeName).toBe(recipeName) expect(args0.ingredients).toEqual(ingredients.split(',')) expect(args0.id).toBeUndefined() })
it("should render a + sign for the correct answer", () => { expect( summary .find("li") .at(0) .find("strong") .text() ).toBe("+"); });
it('Will render player and country picture and alternative text', () => { const player = mount(<Player player={mockPlayer} countryList={mockCountryList} />); expect(player.find('.picture')).to.have.length(2); expect(player.find('.picture img').at(0).prop('src')).to.equal(mockPlayer.picture); expect(player.find('.picture img').at(0).prop('alt')).to.equal(`${mockPlayer.firstname} ${mockPlayer.lastname}`); expect(player.find('.picture img').at(1).prop('src')).to.equal(mockPlayer.country.picture); expect(player.find('.picture img').at(1).prop('alt')).to.equal(mockCountryList[mockPlayer.country.code]); });
it('form submit should call handleFormSubmit function', () => { const component = mount(<ContactForm />) const mockEvent = { preventDefault: jest.fn() } spyOn(component.nodes[0], 'handleFormSubmit').and.callThrough() component.setState({...mockFormData}) component.find('form').at(0).simulate("submit", mockEvent) expect(component.nodes[0].handleFormSubmit).toBeCalled() expect(mockEvent.preventDefault).toBeCalled() })
it("should render the Homepage for the logged in user without tasks", () => { const props = { isLoggedIn: true, username: "Jesse" } const app = mount(<App {...props} />) // Checking output expect(app.find(Home)).toHaveLength(1) expect(app.find('p').at(0).text()).toEqual("Welcome, Jesse!") expect(app.find('li')).toHaveLength(0) })
it('should process basic multiplication when equals is pressed multiple times', () => { const wrapper = mount(<App/>); wrapper.find('.calc__button--numeric').at(2).simulate('click'); wrapper.find('.calc__button--operator').at(2).simulate('click'); wrapper.find('.calc__button--numeric').at(5).simulate('click'); wrapper.find('.calc__button--operator').at(4).simulate('click'); wrapper.find('.calc__button--operator').at(4).simulate('click'); wrapper.find('.calc__button--operator').at(4).simulate('click'); expect(wrapper.state().total).to.equal('250'); });
it('should render 1 PageProgressBar must have not active state', () => { const { component } = renderComponent(); const progressBar = component.find(PageProgressBar).at(0); expect(progressBar.props().isActive).to.equal(false); });
it('should return total when equals is clicked', () => { const wrapper = mount(<App/>); wrapper.find('.calc__button--numeric').at(2).simulate('click'); wrapper.find('.calc__button--numeric').at(0).simulate('click'); wrapper.find('.calc__button--operator').at(4).simulate('click'); expect(wrapper.state().numberToOperateWith).to.equal('20'); });
it('should return total when equals is clicked multiple times', () => { const wrapper = mount(<App/>); wrapper.find('.calc__button--numeric').at(2).simulate('click'); wrapper.find('.calc__button--numeric').at(0).simulate('click'); wrapper.find('.calc__button--operator').at(4).simulate('click'); wrapper.find('.calc__button--operator').at(4).simulate('click'); wrapper.find('.calc__button--operator').at(4).simulate('click'); expect(wrapper.state().numberToOperateWith).to.equal('20'); });
it('should handle basic subtraction', () => { const wrapper = mount(<App/>); wrapper.find('.calc__button--numeric').at(2).simulate('click'); wrapper.find('.calc__button--operator').at(1).simulate('click'); wrapper.find('.calc__button--numeric').at(5).simulate('click'); wrapper.find('.calc__button--operator').at(4).simulate('click'); expect(wrapper.state().total).to.equal('-3'); });