cress-type
detect whether one is similiar to another
Last updated 5 years ago by xinchaobeta .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cress-type 
SYNC missed versions from official npm registry.

Cress Type

This is an addon plugin for the Jest test framework, the chai assertion library and the should.js assertion library. It provides the most basic function type compare ability and tests.

Installation

Node.js

Cress Type are available on npm.

  $ npm install cress-type

Usage

Use As a Jest Plug In

In order to load the plugin, add Jest config option to the package.json file:

// package.json
  ... 
  "jest": {
    "setupTestFrameworkScriptFile": "<rootDir>/node_modules/cress-type/dest/jest.js"
  }

Then you can use it in Jest test files:

// __tests__/example.js

data1 = ['example', 1, {user: {name: 'cress', age: 99} }]
data2 = ['another example', 2, {user: {name: 'haha', age: 0}}]

expect(data1).toBeCompatible(data2)

Use As a Chai Plug In

var chai = require('chai')
  , compatible = require('cress-type/dest/chai');

chai.use(compatible);

var should = chai.should()
  , expect = chai.expect;

data1 = ['example', 1, {user: {name: 'cress', age: 99} }]
data2 = ['another example', 2, {user: {name: 'haha', age: 0}}]

//expect mode
expect(data1).to.be.compatible(data2)

//should mode
data1.should.be.compatible(data2)

Use As a Should.js Plug In

var Should = require('should')
  , compatible = require('cress-type/dest/should');

Should.use(compatible);

data1 = ['example', 1, {user: {name: 'cress', age: 99} }]
data2 = ['another example', 2, {user: {name: 'haha', age: 0}}]

data1.should.be.compatible(data2)

Use Not As Plug In

var compatible = require('cress-type');

data1 = ['example', 1, {user: {name: 'cress', age: 99} }]
data2 = ['another example', 2, {user: {name: 777, age: 0}}]

compatible(data1, data2)  

//will output: {isCompatible: false, path: '[2].user.name'}
//  which means
//           typeof data1[2].user.name !== typeof data2[2].user.name

License

(The MIT License)

Current Tags

  • 0.4.1                                ...           latest (5 years ago)

8 Versions

  • 0.4.1                                ...           5 years ago
  • 0.4.0                                ...           5 years ago
  • 0.3.1                                ...           5 years ago
  • 0.3.0                                ...           5 years ago
  • 0.2.2                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |