Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save erezLieberman/fec54d616915d7c7e58c9bde4fa20eec to your computer and use it in GitHub Desktop.

Select an option

Save erezLieberman/fec54d616915d7c7e58c9bde4fa20eec to your computer and use it in GitHub Desktop.

Revisions

  1. Erez Lieberman revised this gist Aug 22, 2018. No changes.
  2. Erez Lieberman revised this gist Aug 22, 2018. 1 changed file with 6 additions and 7 deletions.
    13 changes: 6 additions & 7 deletions Basic for test component method in react + jest + enzyme.js
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,20 @@
    import React from 'react';
    import _ from 'lodash';
    import { mount, shallow } from 'enzyme';
    import ProgressBar from '../src/ProgressBar';
    import NameOfComponent from '../src/NameOfComponent';

    describe('ProgressBar Basic: ', () => {
    describe('NameOfComponent Basic: ', () => {

    it('should verified that component is exits', () => {
    const wrapper = mount(
    <ProgressBar />
    <NameOfComponent />
    );
    expect(wrapper).toHaveLength(1);
    });

    it('should verified that getWidth component works as as expected', () => {
    const wrapper = mount(shallow(<ProgressBar total={200} value={15} />).get(0));
    wrapper.setState({ noWidth:false });
    expect(wrapper.instance().getWidth()).toEqual(7.5);
    it('should verified that method name component works as as expected', () => {
    const wrapper = mount(shallow(<NameOfComponent propsname={200} />).get(0));
    expect(wrapper.instance().methodName()).toEqual(someValue);
    });

    });
  3. Erez Lieberman created this gist Aug 22, 2018.
    21 changes: 21 additions & 0 deletions Basic for test component method in react + jest + enzyme.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import React from 'react';
    import _ from 'lodash';
    import { mount, shallow } from 'enzyme';
    import ProgressBar from '../src/ProgressBar';

    describe('ProgressBar Basic: ', () => {

    it('should verified that component is exits', () => {
    const wrapper = mount(
    <ProgressBar />
    );
    expect(wrapper).toHaveLength(1);
    });

    it('should verified that getWidth component works as as expected', () => {
    const wrapper = mount(shallow(<ProgressBar total={200} value={15} />).get(0));
    wrapper.setState({ noWidth:false });
    expect(wrapper.instance().getWidth()).toEqual(7.5);
    });

    });