bn-chai
bn-chai extends Chai with assertions about bn.js decimals.
Installation
npm install -s bn-chai
Setup
var chai = ;var BN = ;var bnChai = ;chai;
Usage
When comparing two bn.js decimals bn1 and bn2, instead of doing:
tobetrue;
You can do this instead:
toeq;
This plugin is also handy when comparing a bn.js decimal to an inline constant, so instead of writing:
tobetrue;
You can simply write:
toeq;
Which is simpler and more readable.
Assertions
eq
Asserts that the target is equal to the given object.
toeq;nottoeq;
lt
Asserts that the target is less than the given object.
tobelt;nottobelt;
lte
Asserts that the target is less than or equal to the given object.
tobelte;tobelte;nottobelte;
gt
Asserts that the target is greater than the given object.
tobegt;nottobegt;
gte
Asserts that the target is greater than or equal to the given object.
tobegte;tobegte;nottobegte;
negative
Asserts that the target is negative.
tobenegative;nottobenegative;
even
Asserts that the target is even.
tobeeven;nottobeeven;
odd
Asserts that the target is odd.
tobeodd;nottobeodd;
zero
Asserts that the target is equal to 0.
tobezero;nottobezero;
Mixing BN, numbers and strings
You can mix BN with numbers and strings freely:
toeq;toeq;toeq; toeq;toeq;toeq; toeq;toeq;toeq;