How to use the expect.js.Assertion function in expect

To help you get started, we’ve selected a few expect 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 peerigon / alamid / test / testHelpers / expect.jquery.js View on Github external
"use strict"; // run code in ES5 strict mode

var expect = require("expect.js"),
    $ = require("../testHelpers/jquery.js");

var proto = expect.Assertion.prototype,
    be = proto.be,
    eql = proto.eql,
    a = proto.a,
    contain = proto.contain,
    empty = proto.empty;

// don't extend it when it's already extended
if (!expect.jQuery) {
    expect.jQuery = true;

    proto.be =
    proto.equal = function (obj) {
        this.obj = unwrap(this.obj);
        obj = unwrap(obj);
        be.call(this, obj);
    };
github regularjs / regular / test / spec / test-lexer.js View on Github external
var expect = require('expect.js');
var ao = expect.Assertion.prototype;
ao.typeEqual = function(list){
  if(typeof list == 'string') list = list.split(',')
  var types = this.obj.map(function(item){
    return item.type
  });
  this.assert(
      expect.eql(types, list) 
    , function(){ return 'expected ' + list + ' to equal ' + types }
    , function(){ return 'expected ' + list + ' to not equal ' + types });
  return this;
}

var Lexer = require("../../lib/parser/Lexer.js");
var config = require("../../lib/config.js");

var Regular = require("../../lib/index.js");
github regularjs / regular / test / spec / test-lexer.js View on Github external
var types = this.obj.map(function(item){
    return item.type
  });
  this.assert(
      expect.eql(types, list) 
    , function(){ return 'expected ' + list + ' to equal ' + types }
    , function(){ return 'expected ' + list + ' to not equal ' + types });
  return this;
}

var Lexer = require("../../lib/parser/Lexer.js");
var config = require("../../lib/config.js");

var Regular = require("../../lib/index.js");

var ao = expect.Assertion.prototype;

/**
 * setup template
 */

ao.typeEqual = function(list){
  if(typeof list == 'string') list = list.split(',')
  var types = this.obj.map(function(item){
    return item.type
  });
  this.assert(
      expect.eql(types, list) 
    , function(){ return 'expected ' + list + ' to equal ' + types }
    , function(){ return 'expected ' + list + ' to not equal ' + types });
  return this;
}
github cloudinary / cloudinary_npm / test / spechelper.js View on Github external
exports.LARGE_RAW_FILE = "test/resources/TheCompleteWorksOfShakespeare.mobi";
exports.LARGE_VIDEO = "test/resources/CloudBookStudy-HD.mp4";
exports.EMPTY_IMAGE = "test/resources/empty.gif";
exports.RAW_FILE = "test/resources/docx.docx";
exports.ICON_FILE = "test/resources/favicon.ico";
exports.IMAGE_URL = "http://res.cloudinary.com/demo/image/upload/sample";

exports.test_cloudinary_url = function (public_id, options, expected_url, expected_options) {
  var url;
  url = utils.url(public_id, options);
  expect(url).to.eql(expected_url);
  expect(options).to.eql(expected_options);
  return url;
};

expect.Assertion.prototype.produceUrl = function (url) {
  var actual, actualOptions, options, public_id;
  [public_id, options] = this.obj;
  actualOptions = cloneDeep(options);
  actual = utils.url(public_id, actualOptions);
  this.assert(actual.match(url), function () {
    return `expected '${public_id}' and ${JSON.stringify(options)} to produce '${url}' but got '${actual}'`;
  }, function () {
    return `expected '${public_id}' and ${JSON.stringify(options)} not to produce '${url}' but got '${actual}'`;
  });
  return this;
};

expect.Assertion.prototype.emptyOptions = function () {
  var actual, options, public_id;
  [public_id, options] = this.obj;
  actual = cloneDeep(options);
github artsy / metaphysics / test / helper.js View on Github external
)
  );
};

/**
 * A `expect` test matcher that is used to check if a promise was resolved or not.
 *
 * This matcher only exists because just returning a promise from a test that contains no `expect`
 * calls looks a bit lame, but in reality this matcher wouldn’t need to exist, as a test will
 * automatically fail if a returned promise fails. This is also why there’s no `resolvedWith`
 * matcher, because in that case the `resolve` callback of the promise would contain an `expect`
 * call.
 *
 * @returns {Promise}
 */
expect.Assertion.prototype.resolved = function resolved() {
  this.flags.not = !this.flags.not;
  return this.rejected();
};
github y8n / xg-htmlhint / test / htmlparser.spec.js View on Github external
/**
 * Copyright (c) 2015, Yanis Wang 
 * Copyright (c) 2015, YangJiyuan 
 * MIT Licensed
 */

var expect  = require("expect.js");

var HTMLParser  = require("../index").HTMLParser;

expect.Assertion.prototype.event = function(type, attr){
    var self = this,
        obj = self.obj;
    if(attr !== undefined){
        attr.type = type;
    }
    else{
        attr = {'type': type};
    }
    self.assert(
        eqlEvent(obj, attr),
        function(){ return 'expected "'+JSON.stringify(obj)+'" to event "'+JSON.stringify(attr)+'"'; },
        function(){ return 'expected "'+JSON.stringify(obj)+'" not to event "'+JSON.stringify(attr)+'"'; });
};

function eqlEvent(event, attr){
    for(var name in attr){
github bnoguchi / everyauth / test / util / expect.js View on Github external
var expect = require('expect.js');

/**
 * Adapted from Tobi to work with expect.js
 *
 * Tobi - assertions - should
 * Copyright(c) 2010 LearnBoost 
 * MIT Licensed
 */
var Assertion = expect.Assertion
  , statusCodes = require('http').STATUS_CODES
  , j = function(elem){ return '[jQuery ' + i(elem.selector.replace(/^ *\* */, '')) + ']'; }
  , i = require('sys').inspect;

/**
 * Number strings.
 */

var nums = [
    'none'
  , 'one'
  , 'two'
  , 'three'
  , 'four'
  , 'five'
];
github htmlhint / HTMLHint / test / htmlparser.spec.js View on Github external
const expect = require('expect.js');

const HTMLParser = require('../dist/htmlhint.js').HTMLParser;

expect.Assertion.prototype.event = function(type, attr) {
  const self = this;
  const obj = self.obj;

  if (attr !== undefined) {
    attr.type = type;
  } else {
    if (typeof attr === 'string') {
      attr = { type: type };
    } else {
      attr = type;
    }
  }
  self.assert(
    eqlEvent(obj, attr),
    () =>
      `expected "${JSON.stringify(obj)}" to event "${JSON.stringify(attr)}"`,
github redux-things / redux-actions-assertions / src / expectjs.js View on Github external
function registerAssertions() {
  expect.Assertion.prototype.withState = withState;
  expect.Assertion.prototype.dispatchActions = dispatchActions;
}
github redux-things / redux-actions-assertions / src / expectjs.js View on Github external
function registerAssertions() {
  expect.Assertion.prototype.withState = withState;
  expect.Assertion.prototype.dispatchActions = dispatchActions;
}

expect

This package exports the `expect` function used in [Jest](https://jestjs.io/). You can find its documentation [on Jest's website](https://jestjs.io/docs/expect).

MIT
Latest version published 8 months ago

Package Health Score

93 / 100
Full package analysis