Chai assertions for BEM class names
Install
npm i chai-bem
Usage
Plug-in the plugin first:
;; chai;
Both classNames and DOM elements are supported:
tobea;tobea;
BEM naming rules
You can set optional BEM naming rules (default values and available options are the same as in bem-naming), for example:
chai;
entityHook option
If you want chai-bem
hooks to work with entity types other than DOM nodes or classNames,
you can add entityHook
option. Example:
; chai
Block
block
methodvalidBlock
property
Examples:
// check if it's an `input` blocktobea; // or you can just check if it's a valid block at alltobeavalidBlock; // this will throw an errortobeavalidBlock;
Element
elem
methodvalidElem
property
tobean; // is it a valid element at alltobeavalidElem; // this will throw an errortobeavalidElem;
Modificators
mods
method
// you can check one modificator (both block and element mods are supported)tohave;tohave; // or you can check a bunchtohave; // this will throw an error because both mods were expectedtohave; // you can check boolean modificators as well (both explicit and implicit)tohave;tohave;
BEMJSON
bemjson
orbem
method
// block with a couple of modstobe; // element with a couple of mixestobe;
.not
.not
is supported for all assertions. Examples:
tonotbeavalidBlock; tonothave;