How to use the enzyme.ShallowWrapper.prototype 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 react-bootstrap / react-bootstrap / test / index.js View on Github external
Enzyme.configure({ adapter: new Adapter() });

function assertLength(length) {
  return function $assertLength(selector) {
    let result = this.find(selector);
    expect(result).to.have.length(length);
    return result;
  };
}

ReactWrapper.prototype.assertSingle = assertLength(1);
ShallowWrapper.prototype.assertSingle = assertLength(1);

ReactWrapper.prototype.assertNone = assertLength(0);
ShallowWrapper.prototype.assertNone = assertLength(0);

beforeEach(() => {
  /* eslint-disable no-console */
  sinon.stub(console, 'error').callsFake(msg => {
    let expected = false;

    console.error.expected.forEach(about => {
      if (msg.indexOf(about) !== -1) {
        console.error.warned[about] = true;
        expected = true;
      }
    });

    if (expected) {
      return;
    }
github react-bootstrap / react-bootstrap / test / index.js View on Github external
import deprecated from 'prop-types-extra/lib/deprecated';

import { _resetWarned } from '../src/utils/deprecationWarning';

Enzyme.configure({ adapter: new Adapter() });

function assertLength(length) {
  return function $assertLength(selector) {
    let result = this.find(selector);
    expect(result).to.have.length(length);
    return result;
  };
}

ReactWrapper.prototype.assertSingle = assertLength(1);
ShallowWrapper.prototype.assertSingle = assertLength(1);

ReactWrapper.prototype.assertNone = assertLength(0);
ShallowWrapper.prototype.assertNone = assertLength(0);

beforeEach(() => {
  /* eslint-disable no-console */
  sinon.stub(console, 'error').callsFake(msg => {
    let expected = false;

    console.error.expected.forEach(about => {
      if (msg.indexOf(about) !== -1) {
        console.error.warned[about] = true;
        expected = true;
      }
    });
github react-bootstrap / react-overlays / test / index.js View on Github external
return result;
  };
}

function print() {
  return this.tap(f => console.log(f.debug()));
}

ReactWrapper.prototype.assertSingle = assertLength(1);
ShallowWrapper.prototype.assertSingle = assertLength(1);

ReactWrapper.prototype.assertNone = assertLength(0);
ShallowWrapper.prototype.assertNone = assertLength(0);

ReactWrapper.prototype.print = print;
ShallowWrapper.prototype.print = print;

chai.should();
chai.use(sinonChai);

global.expect = chai.expect;
global.assert = chai.assert;

beforeEach(() => {
  sinon.stub(console, 'error').callsFake(msg => {
    let expected = false;

    console.error.expected.forEach(about => {
      if (msg.indexOf(about) !== -1) {
        console.error.warned[about] = true;
        expected = true;
      }
github react-bootstrap / react-overlays / test / index.js View on Github external
Enzyme.configure({ adapter: new Adapter() });

function assertLength(length) {
  return function $assertLength(selector) {
    let result = this.find(selector);
    expect(result).to.have.length(length);
    return result;
  };
}

function print() {
  return this.tap(f => console.log(f.debug()));
}

ReactWrapper.prototype.assertSingle = assertLength(1);
ShallowWrapper.prototype.assertSingle = assertLength(1);

ReactWrapper.prototype.assertNone = assertLength(0);
ShallowWrapper.prototype.assertNone = assertLength(0);

ReactWrapper.prototype.print = print;
ShallowWrapper.prototype.print = print;

chai.should();
chai.use(sinonChai);

global.expect = chai.expect;
global.assert = chai.assert;

beforeEach(() => {
  sinon.stub(console, 'error').callsFake(msg => {
    let expected = false;
github react-bootstrap / react-overlays / test / index.js View on Github external
return function $assertLength(selector) {
    let result = this.find(selector);
    expect(result).to.have.length(length);
    return result;
  };
}

function print() {
  return this.tap(f => console.log(f.debug()));
}

ReactWrapper.prototype.assertSingle = assertLength(1);
ShallowWrapper.prototype.assertSingle = assertLength(1);

ReactWrapper.prototype.assertNone = assertLength(0);
ShallowWrapper.prototype.assertNone = assertLength(0);

ReactWrapper.prototype.print = print;
ShallowWrapper.prototype.print = print;

chai.should();
chai.use(sinonChai);

global.expect = chai.expect;
global.assert = chai.assert;

beforeEach(() => {
  sinon.stub(console, 'error').callsFake(msg => {
    let expected = false;

    console.error.expected.forEach(about => {
      if (msg.indexOf(about) !== -1) {
github jquense / react-formal / test / index.js View on Github external
configure({ adapter: new Adapter() })

function assertLength(length) {
  return function $assertLength(selector) {
    let result = this.find(selector)
    result.should.have.length(length)
    return result
  }
}
ReactWrapper.prototype.print = function print() {
  console.log(this.debug())
  return this
}

ReactWrapper.prototype.assertSingle = assertLength(1)
ShallowWrapper.prototype.assertSingle = assertLength(1)

ReactWrapper.prototype.assertNone = assertLength(0)
ShallowWrapper.prototype.assertNone = assertLength(0)
github jquense / react-formal / test / index.js View on Github external
return function $assertLength(selector) {
    let result = this.find(selector)
    result.should.have.length(length)
    return result
  }
}
ReactWrapper.prototype.print = function print() {
  console.log(this.debug())
  return this
}

ReactWrapper.prototype.assertSingle = assertLength(1)
ShallowWrapper.prototype.assertSingle = assertLength(1)

ReactWrapper.prototype.assertNone = assertLength(0)
ShallowWrapper.prototype.assertNone = assertLength(0)