expect-renum
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;; expect; // not using an ES6 transpilervar expect = ;var expectRenum = ; expect;
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
.
// ✔ // ✘
toNotHaveEnumKey
expect(enum).toNotHaveEnumKey(key, [message])
Asserts the given enum
object has not an attribute with the given key
.
// ✔ // ✘
toHaveEnumKeys
expect(enum).toHaveEnumKeys(keys)
Asserts the given enum
object has all given keys
attributes.
// ✔ // ✔ // ✘ // ✘
toNotHaveEnumKeys
expect(enum).toNotHaveEnumKeys(keys)
Asserts the given enum
object has not any given keys
attributes.
// ✔ // ✔ // ✘ // ✘ // ✘
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.
// ✔ // ✘
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.
// ✔ // ✔ // ✔ // ✘
toBeEditable
expect(obj).toBeEditable()
Asserts the given obj
object to be editable.
// ✔ // ✘
toNotBeEditable
expect(enum).toNotBeEditable()
Asserts the given enum
object to not be editable.
// ✔ // ✘
toHaveProp
expect(obj).toHaveProp(key)
Asserts the given obj
object has a property with the given key
.
// ✔ // ✘
toNotHaveProp
expect(obj).toNotHaveProp(key)
Asserts the given obj
object has not a property with the given key
.
// ✔ // ✘
toBeIn
expect(key).toBeIn(obj)
Asserts the given key
string is in the given obj
object.
// ✔ // ✘
toNotBeIn
expect(key).toNotBeIn(obj)
Asserts the given key
string is not in the given obj
object.
// ✔ // ✘
toBeFrozen
expect(obj).toBeFrozen()
Asserts the given obj
object is frozen.
// ✔ // ✔ // ✘
toNotBeFrozen
expect(obj).toNotBeFrozen()
Asserts the given obj
object is not frozen.
// ✔ // ✘ // ✘