Sha256: d1febfae0a96dc2a1f959a17de299f17d7bce0863c19ecfd3315f49629ea2747

Contents?: true

Size: 1.92 KB

Versions: 16

Compression:

Stored size: 1.92 KB

Contents

/*!
 * Should
 * Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
 * MIT Licensed
 */

var util = require('../util');

module.exports = function(should, Assertion) {
  Assertion.add('Number', function() {
    this.params = { operator: 'to be a number' };

    this.assert(util.isNumber(this.obj));
  }, true);

  Assertion.add('arguments', function() {
    this.params = { operator: 'to be arguments' };

    this.assert(util.isArguments(this.obj));
  }, true);

  Assertion.add('type', function(type, description) {
    this.params = { operator: 'to have type ' + type, message: description };

    (typeof this.obj).should.be.exactly(type, description);
  });

  Assertion.add('instanceof', function(constructor, description) {
    this.params = { operator: 'to be an instance of ' + constructor.name, message: description };

    this.assert(Object(this.obj) instanceof constructor);
  });

  Assertion.add('Function', function() {
    this.params = { operator: 'to be a function' };

    this.assert(util.isFunction(this.obj));
  }, true);

  Assertion.add('Object', function() {
    this.params = { operator: 'to be an object' };

    this.assert(util.isObject(this.obj));
  }, true);

  Assertion.add('String', function() {
    this.params = { operator: 'to be a string' };

    this.assert(util.isString(this.obj));
  }, true);

  Assertion.add('Array', function() {
    this.params = { operator: 'to be an array' };

    this.assert(Array.isArray(this.obj));
  }, true);

  Assertion.add('Boolean', function() {
    this.params = { operator: 'to be a boolean' };

    this.assert(util.isBoolean(this.obj));
  }, true);

  Assertion.add('Error', function() {
    this.params = { operator: 'to be an error' };

    this.assert(util.isError(this.obj));
  }, true);

  Assertion.add('null', function() {
    this.params = { operator: 'to be null' };

    this.assert(this.obj === null);
  }, true);

  Assertion.alias('instanceof', 'instanceOf');
};

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
stylus-source-0.42.2 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.42.1 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.42.0 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.41.3 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.41.2 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.41.1 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.41.0 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.40.3 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.40.2 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.40.1 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.40.0 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.39.4 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.39.3 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.39.2 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.39.1 vendor/node_modules/should/lib/ext/type.js
stylus-source-0.39.0 vendor/node_modules/should/lib/ext/type.js