Skip to content
This repository has been archived by the owner on Jun 6, 2020. It is now read-only.

[Feature] UI Template #10

Merged
merged 4 commits into from
Sep 3, 2019
Merged

[Feature] UI Template #10

merged 4 commits into from
Sep 3, 2019

Conversation

imteekay
Copy link
Owner

@imteekay imteekay commented Sep 3, 2019

UI Template

A new UI Template looking like:

import React from 'react';
import { shallow } from 'enzyme';

import ${componentToBeTested} from '../${componentToBeTested}';

describe('${componentToBeTested}', () => {
  let renderedComponent;

  const defaultProps = {
    someProp: 'someProp',
  };

  const render = (props) => shallow(<${componentToBeTested} {...defaultProps} {...props} />);

  beforeAll(() => {
    renderedComponent = render();
  });

  describe('UI', () => {
    describe('renders <AnotherComponent /> with correct props', () => {
      let anotherComponent;
      let componentProps;

      beforeAll(() => {
        anotherComponent = renderedComponent.find(AnotherComponent);
        componentProps = anotherComponent.props();
      });

      it('finds the other component inside the main component', () => {
        expect(anotherComponent).toHaveLength(1);
      });

      it('has the main props', () => {
        expect(componentProps).toMatchObject({
          someProp: defaultProps.someProp,
        });
      });
    });
  });
});

@imteekay imteekay added the enhancement New feature or request label Sep 3, 2019
@imteekay imteekay self-assigned this Sep 3, 2019
@imteekay imteekay merged commit 343fd09 into master Sep 3, 2019
@imteekay imteekay deleted the feat/ui-template branch September 3, 2019 12:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant