npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

expect-renum

v1.0.2

Published

Expect extra test for renum package.

Downloads

2

Readme

expect-renum npm package Travis Coveralls

expect-renum is an extension for expect that lets you write better assertions for Enum or Immutable data in javascript.

Installation

Using npm:

$ npm install expect expect-renum --save-dev

Then with a module bundler like webpack, use as you would anything else:

// using an ES6 transpiler, like babel
import expect from 'expect';
import expectRenum from 'expect-renum';

expect.extend(expectRenum);

// not using an ES6 transpiler
var expect = require('expect');
var expectRenum = require('expect-renum');

expect.extend(expectRenum);

Assertions

// ✔ === success (passed the test) // ✘ === failure (throw exception)

toHaveEnumKey

expect(enum).toHaveEnumKey(key, [message])

Asserts the given enum object has an attribute with the given key.

expect(renum('TRUE', 'FALSE')).toHaveEnumKey('TRUE') // ✔
expect(renum('TRUE', 'FALSE')).toHaveEnumKey('MAYBE') // ✘

toNotHaveEnumKey

expect(enum).toNotHaveEnumKey(key, [message])

Asserts the given enum object has not an attribute with the given key.

expect(renum('TRUE', 'FALSE')).toNotHaveEnumKey('MAYBE') // ✔
expect(renum('TRUE', 'FALSE')).toNotHaveEnumKey('TRUE') // ✘

toHaveEnumKeys

expect(enum).toHaveEnumKeys(keys)

Asserts the given enum object has all given keys attributes.

expect(renum('TRUE', 'FALSE')).toHaveEnumKeys(['TRUE']) // ✔
expect(renum('TRUE', 'FALSE')).toHaveEnumKeys(['TRUE', 'FALSE']) // ✔
expect(renum('TRUE', 'FALSE')).toHaveEnumKeys(['MAYBE']) // ✘
expect(renum('TRUE', 'FALSE')).toHaveEnumKeys(['TRUE', 'FALSE', 'MAYBE']) // ✘

toNotHaveEnumKeys

expect(enum).toNotHaveEnumKeys(keys)

Asserts the given enum object has not any given keys attributes.

expect(renum('TRUE', 'FALSE')).toNotHaveEnumKeys(['MAYBE']) // ✔
expect(renum('TRUE', 'FALSE')).toNotHaveEnumKeys(['MAYBE', 'MAYBE_NOT']) // ✔
expect(renum('TRUE', 'FALSE')).toNotHaveEnumKeys(['TRUE']) // ✘
expect(renum('TRUE', 'FALSE')).toNotHaveEnumKeys(['TRUE', 'FALSE']) // ✘
expect(renum('TRUE', 'FALSE')).toNotHaveEnumKeys(['TRUE', 'FALSE', 'MAYBE']) // ✘

toHaveEnumPair

expect(enum).toHaveEnumPair(pair, [message])

Asserts the given enum object has an attribute with the given pair[0] key pointing to given pair[1] value.

expect(renum('TRUE', 'FALSE')).toHaveEnumPair(['TRUE', 'TRUE']) // ✔
expect(renum('TRUE', 'FALSE')).toHaveEnumPair(['MAYBE', 'MAYBE']) // ✘

toNotHaveEnumPair

expect(enum).toNotHaveEnumPair(pair, [message])

Asserts the given enum object has not an attribute with the given pair[0] key pointing to given pair[1] value.

expect(renum('TRUE', 'FALSE')).toNotHaveEnumPair(['MAYBE', 'MAYBE']) // ✔
expect(renum('TRUE', 'FALSE')).toNotHaveEnumPair(['TRUE', 1]) // ✔
expect(renum('TRUE', 'FALSE')).toNotHaveEnumPair([1, 'TRUE']) // ✔
expect(renum('TRUE', 'FALSE')).toNotHaveEnumPair(['TRUE', 'TRUE']) // ✘

toBeEditable

expect(obj).toBeEditable()

Asserts the given obj object to be editable.

expect({TRUE: 'TRUE', FALSE: 'FALSE'}).toBeEditable() // ✔
expect(renum('TRUE', 'FALSE')).toBeEditable() // ✘

toNotBeEditable

expect(enum).toNotBeEditable()

Asserts the given enum object to not be editable.

expect(renum('TRUE', 'FALSE')).toNotBeEditable() // ✔
expect({TRUE: 'TRUE', FALSE: 'FALSE'}).toNotBeEditable() // ✘

toHaveProp

expect(obj).toHaveProp(key)

Asserts the given obj object has a property with the given key.

expect({TRUE: 1, FALSE: 0}).toHaveProp('TRUE') // ✔
expect({TRUE: 1, FALSE: 0}).toHaveProp('MAYBE') // ✘

toNotHaveProp

expect(obj).toNotHaveProp(key)

Asserts the given obj object has not a property with the given key.

expect({TRUE: 1, FALSE: 0}).toNotHaveProp('MAYBE') // ✔
expect({TRUE: 1, FALSE: 0}).toNotHaveProp('TRUE') // ✘

toBeIn

expect(key).toBeIn(obj)

Asserts the given key string is in the given obj object.

expect('TRUE').toBeIn({TRUE: 1, FALSE: 0}) // ✔
expect('MAYBE').toBeIn({TRUE: 1, FALSE: 0}) // ✘

toNotBeIn

expect(key).toNotBeIn(obj)

Asserts the given key string is not in the given obj object.

expect('MAYBE').toNotBeIn({TRUE: 1, FALSE: 0}) // ✔
expect('TRUE').toNotBeIn({TRUE: 1, FALSE: 0}) // ✘

toBeFrozen

expect(obj).toBeFrozen()

Asserts the given obj object is frozen.

expect(renum([['TRUE', 1], ['FALSE', 0]])).toBeFrozen() // ✔
expect(Object.freeze({TRUE: 1, FALSE: 0})).toBeFrozen() // ✔
expect({TRUE: 1, FALSE: 0}).toBeFrozen() // ✘

toNotBeFrozen

expect(obj).toNotBeFrozen()

Asserts the given obj object is not frozen.

expect({TRUE: 1, FALSE: 0}).toNotBeFrozen() // ✔
expect(renum([['TRUE', 1], ['FALSE', 0]])).toNotBeFrozen() // ✘
expect(Object.freeze({TRUE: 1, FALSE: 0})).toNotBeFrozen() // ✘