diff --git a/src/index.js b/src/index.js index 894ca2af..547187bf 100644 --- a/src/index.js +++ b/src/index.js @@ -707,7 +707,7 @@ module.exports = { ' to only have (class|classes) ', (expect, subject, value) => expect(subject, 'to have attributes', { - class: className => { + class: expect.it(className => { const actualClasses = getClassNamesFromAttributeValue(className); if (typeof value === 'string') { value = getClassNamesFromAttributeValue(value); @@ -715,7 +715,7 @@ module.exports = { return bubbleError(() => expect(actualClasses.sort(), 'to equal', value.sort()) ); - } + }) }) ); @@ -1104,6 +1104,13 @@ module.exports = { expect(attrs.style, 'to satisfy', expectedStyleObj) ); } + } else if ( + expect.findTypeOf(expectedAttributeValue).is('expect.it') + ) { + expect.context.thisObject = subject; + return bubbleError(() => + expectedAttributeValue(attributeValue, expect.context) + ); } else { return bubbleError(() => expect(attributeValue, 'to satisfy', expectedAttributeValue)