How to use the enzyme.ReactWrapper function in enzyme

To help you get started, we’ve selected a few enzyme examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github instructure / instructure-ui / tests / util / testbed.js View on Github external
ReactWrapper.prototype.ref = function () {
  const ref = arguments[0]
  const instance = this.instance()
  // eslint-disable-next-line no-prototype-builtins
  if (instance.hasOwnProperty(ref)) {
    return new ReactWrapper(instance[ref], true)
  } else {
    return originalRef.apply(this, arguments)
  }
}
github instructure / instructure-ui / packages / ui-testbed / lib / enzymeWrapper.js View on Github external
ReactWrapper.prototype.ref = function () {
  const ref = arguments[0]
  const instance = this.instance()
  // eslint-disable-next-line no-prototype-builtins
  if (instance.hasOwnProperty(ref)) {
    return new ReactWrapper(instance[ref], true)
  } else if (typeof originalRef === 'function') {
    return originalRef.apply(this, arguments)
  }
}
github youzan / zent / packages / zent / __tests__ / datetimepicker / DatePicker.js View on Github external
it('support disabled time with min', () => {
    const now = setTime(new Date(), TIME);

    const wrapper = mount();
    wrapper.find('.picker-input').simulate('click');
    const pop = new ReactWrapper(wrapper.instance().picker, true);

    pop.find('DatePanel .panel__cell--current').simulate('click');
    pop
      .find('TimePanel .time__number')
      .first()
      .simulate('click');

    expect(
      pop
        .find('HourPanel .panel__cell')
        .at(HOURS - 1)
        .hasClass('panel__cell--disabled')
    ).toBe(true);

    pop
      .find('HourPanel .panel__cell')
github youzan / zent / packages / zent / __tests__ / datetimepicker / MonthPicker.js View on Github external
it('MonthPicker has 2 level panel', () => {
    let pop;
    const wrapper = mount();
    const inst = wrapper.instance();
    expect(inst.state.openPanel).toBe(false);
    expect(inst.state.showPlaceholder).toBe(true);
    wrapper.find('.picker-input').simulate('click');
    expect(inst.state.openPanel).toBe(true);

    pop = new ReactWrapper(inst.picker, true);
    expect(pop.find('MonthPanel').length).toBe(1);
    expect(pop.find('.grid-cell').length).toBe(12);

    const click = new Event('click');
    document.dispatchEvent(click);
    expect(inst.state.openPanel).toBe(false);
    expect(wrapper.find('ClosablePortal').prop('visible')).toBe(false);
    wrapper.find('.picker-input').simulate('click');

    pop.find('.panel__title').simulate('click');
    expect(pop.find('YearPanel').length).toBe(1);
    expect(pop.find('YearPanel .grid-cell').length).toBe(12);

    pop
      .find('YearPanel .panel__cell')
      .at(1)
github DefinitelyTyped / DefinitelyTyped / types / enzyme / enzyme-tests.tsx View on Github external
function test_constructor() {
        let anyWrapper: ReactWrapper;
        anyWrapper = new ReactWrapper();
        reactWrapper = new ReactWrapper();
        reactWrapper = new ReactWrapper([, ]);
        reactWrapper = new ReactWrapper(, reactWrapper);
        reactWrapper = new ReactWrapper(, undefined, { attachTo: document.createElement('div') });
        reactWrapper = new ReactWrapper(, reactWrapper, { attachTo: document.createElement('div') });
    }
github DefinitelyTyped / DefinitelyTyped / types / enzyme / enzyme-tests.tsx View on Github external
function test_constructor() {
        let anyWrapper: ReactWrapper;
        anyWrapper = new ReactWrapper();
        reactWrapper = new ReactWrapper();
        reactWrapper = new ReactWrapper([, ]);
        reactWrapper = new ReactWrapper(, reactWrapper);
        reactWrapper = new ReactWrapper(, undefined, { attachTo: document.createElement('div') });
        reactWrapper = new ReactWrapper(, reactWrapper, { attachTo: document.createElement('div') });
    }
github DefinitelyTyped / DefinitelyTyped / types / enzyme / enzyme-tests.tsx View on Github external
function test_constructor() {
        let anyWrapper: ReactWrapper;
        anyWrapper = new ReactWrapper();
        reactWrapper = new ReactWrapper();
        reactWrapper = new ReactWrapper([, ]);
        reactWrapper = new ReactWrapper(, reactWrapper);
        reactWrapper = new ReactWrapper(, undefined, { attachTo: document.createElement('div') });
        reactWrapper = new ReactWrapper(, reactWrapper, { attachTo: document.createElement('div') });
    }
github DefinitelyTyped / DefinitelyTyped / types / enzyme / enzyme-tests.tsx View on Github external
function test_constructor() {
        let anyWrapper: ReactWrapper;
        anyWrapper = new ReactWrapper();
        reactWrapper = new ReactWrapper();
        reactWrapper = new ReactWrapper([, ]);
        reactWrapper = new ReactWrapper(, reactWrapper);
        reactWrapper = new ReactWrapper(, undefined, { attachTo: document.createElement('div') });
        reactWrapper = new ReactWrapper(, reactWrapper, { attachTo: document.createElement('div') });
    }
github mui-org / material-ui / src / transitions / Collapse.spec.js View on Github external
it('should render a wrapper around the children', () => {
    const children = <h1>Hello</h1>;
    const wrapper = shallow({children});
    const child = new ReactWrapper(wrapper.props().children('entered'));
    assert.strictEqual(child.childAt(0).is('div'), true, 'should be a div');
    assert.strictEqual(
      child
        .childAt(0)
        .childAt(0)
        .children()
        .type(),
      'h1',
      'should wrap the children',
    );
  });
github freeCodeCamp / freeCodeCamp / client / epics / frame-epic.js View on Github external
    mount: (node, options) => new ReactWrapper(node, null, {
      ...options,
      adapter: new Adapter15()
    })
  };