GithubHelp home page GithubHelp logo

tomi77 / jasmine-extra-matchers Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 34 KB

A set of Jasmine helpers

License: MIT License

CoffeeScript 55.89% JavaScript 44.11%
matcher jasmine tdd-utilities testing-tools

jasmine-extra-matchers's Introduction

Jasmine Extra Matchers

Build Status Coverage Status Code Climate dependencies Status devDependencies Status peerDependencies Status Dependency Status Downloads

A set of Jasmine 2.x matchers

Table of contents

Installation and usage

Bower

bower install jasmine-extra-matchers
<script src="/bower_components/jasmine-extra-matchers/jasmine-extra-matchers.js"></script>
it('should be a Backbone.Model', function() {
    expect(value).toBeInstanceOf(Backbone.Model)
});

NPM

npm install jasmine-extra-matchers --save-dev
require('jasmine-extra-matchers');

it('should be infinity', function() {
  expect(value).toBeInfinity()
});

Karma

Use karma-jasmine-extra-matchers

Matchers

toBeInstanceOf

Checks whether a value is the instance of type

expect(value).toBeInstanceOf(Backbone.Model)
expect(value).not.toBeInstanceOf(Backbone.Model)

toBeInfinity

Checks whether a value is infinity

expect(Infinity).toBeInfinity()
expect(0).not.toBeInfinity()

hasOwnProperty

Checks whether a value has own property

expect(value).hasOwnProperty('type')
expect(value).not.hasOwnProperty('type')

toBeEven

Checks whether the value is an even number

expect(2).toBeEven()
expect(3).not.toBeEven()

toBeOdd

Checks whether the value is an odd number

expect(3).toBeOdd()
expect(2).not.toBeOdd()

toBeNumeric

Checks whether the value contains a numeric value, regardless of its type. It can be a string containing a numeric value, exponential notation, a Number object, etc.

expect('14').toBeNumeric()
expect('fourteen').not.toBeNumeric()

toBeInteger

Checks whether the value is a numeric integer. A numeric value can be a string containing a number, a Number object, etc.

expect(18).toBeInteger()
expect('18').toBeInteger()
expect(2.5).not.toBeInteger()
expect(-1).toBeInteger()

toBeFloat

Checks whether the value is a "float"

expect(1.1).toBeFloat()
expect(1).not.toBeFloat()
expect(1.0).not.toBeFloat()
expect('2.15').toBeFloat()

toBePositive

Checks whether the value is a positive number

expect(21).toBePositive()
expect(-1).not.toBePositive()

toBeNegative

Checks whether the value is a negative number

expect(-2).toBeNegative()
expect(5).not.toBeNegative()

jasmine-extra-matchers's People

Contributors

tomi77 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.