How to use the unexpected.addType function in unexpected

To help you get started, we’ve selected a few unexpected 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 mickhansen / dataloader-sequelize / resources / mocha-bootload.js View on Github external
inspect: function (value, depth, output, inspect) {
    const name = value.name || value.$modelOptions.name || value._modelOptions.name; // v3 vs v4
    output
      .text(name.singular).text('(')
      .append(inspect(value.get(), depth))
      .text(')');
  },
  equal: function (a, b) {
    const aModel = a.Model || a.constructor; // v3 vs v4
    const bModel = b.Model || b.constructor;
    const pk = aModel.primaryKeyAttribute;
    return aModel.name === bModel.name && a.get(pk) === b.get(pk);
  }
});

unexpected.addType({
  name: 'Sequelize.Association',
  identify: function (value) {
    return value && value instanceof Sequelize.Association;
  },
  inspect: function (value, depth, output) {
    output
      .text(value.associationType).text(': ')
      .text(value.source.name).text(' -> ').text(value.target.name)
      .text('(').text(value.as).text(')');
  },
  equal: function (a, b, equal) {
    return a.associationType === b.associationType && equal(a.source, b.source) && equal(a.target, b.target) && a.as === b.as;
  }
});

unexpected.addAssertion(' [not] to be shimmed', function (expect, subject) {

unexpected

Extensible BDD assertion toolkit

MIT
Latest version published 1 year ago

Package Health Score

60 / 100
Full package analysis