chai-enzyme
Version:
Chai.js assertions for enzyme
31 lines (27 loc) • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = descendants;
function descendants(_ref) {
var wrapper = _ref.wrapper,
markup = _ref.markup,
arg1 = _ref.arg1,
sig = _ref.sig,
flag = _ref.flag;
var exactlyCount = flag(this, 'exactlyCount');
if (exactlyCount || exactlyCount === 0) {
var descendantCount = wrapper.getDescendantsCount(arg1);
this.assert(descendantCount === exactlyCount, function () {
return 'expected ' + sig + ' to have ' + exactlyCount + ' descendants #{exp} but actually found ' + descendantCount + markup();
}, function () {
return 'expected ' + sig + ' not to have ' + exactlyCount + ' descendants #{exp} but actually found ' + descendantCount + markup();
}, arg1);
} else {
this.assert(wrapper.hasDescendants(arg1), function () {
return 'expected ' + sig + ' to have descendants #{exp} ' + markup();
}, function () {
return 'expected ' + sig + ' not to have descendants #{exp} ' + markup();
}, arg1);
}
}