diff --git a/src/__tests__/element-queries.js b/src/__tests__/element-queries.js index 72029c00b..b0dc39c85 100644 --- a/src/__tests__/element-queries.js +++ b/src/__tests__/element-queries.js @@ -199,7 +199,7 @@ test('can get elements labelled with aria-labelledby attribute', () => { expect(getByLabelText('Section One').id).toBe('section-one') }) -test('can get sibling elements with aria-labelledby attrib ute', () => { +test('can get sibling elements with aria-labelledby attribute', () => { const {getAllByLabelText} = render(`
@@ -212,6 +212,73 @@ test('can get sibling elements with aria-labelledby attrib ute', () => { expect(result[0].id).toBe('icon') }) +test('can filter results of label query based on selector', () => { + const {getAllByLabelText} = render(` +
+ + + Some hint text +
+ `) + + const result = getAllByLabelText('Test Label', {selector: '.fancy-input'}) + expect(result).toHaveLength(1) + expect(result[0].id).toBe('input1') +}) + +test('can find any form control when label text is inside other elements', () => { + const {getAllByLabelText} = render(` +