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 isogon / styled-mdl / tests / _setup / until.js View on Github external
return wrapper
  }
  //
  // console.log(wrapper.getElement().type);
  // console.log(selector);

  return selector && wrapper.is(selector)
    ? wrapper.dive()
    : shallowRecursively(wrapper.dive(), selector)
}

function until(selector) {
  return this.single('until', () => shallowRecursively(this, selector))
}

ShallowWrapper.prototype.until = until
github isogon / styled-mdl / tests / _setup / textOnly.js View on Github external
if (!child.children().length) {
        if (child.getElement()) {
          return '' // empty element with no children
        }
        return child.text() // text content
      }
      return textRecursively(child) // element has child nodes
    })
    .join('')
}

function textOnly() {
  return this.single('textOnly', () => textRecursively(this))
}

ShallowWrapper.prototype.textOnly = textOnly
github bowtie-co / houndstooth-ui / src / setupTests.js View on Github external
process.env.PUBLIC_URL = ''

// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', err => {
  throw err
})

// Ensure environment variables are read.
require('../config/env')

configure({ adapter: new Adapter() })

// This allows jest testing to find the Base Component in a HOC.
ShallowWrapper.prototype.until = until

function storageMock () {
  var storage = {}

  return {
    setItem: function (key, value) {
      storage[key] = value || ''
    },
    getItem: function (key) {
      return key in storage ? storage[key] : null
    },
    removeItem: function (key) {
      delete storage[key]
    },
    get length () {
      return Object.keys(storage).length