diff --git a/src/api/attributes.spec.ts b/src/api/attributes.spec.ts index 9b1c64cbcd..fbea830451 100644 --- a/src/api/attributes.spec.ts +++ b/src/api/attributes.spec.ts @@ -321,6 +321,11 @@ describe('$(...)', () => { expect($(undefined).prop('href')).toBeUndefined(); }); + it('("href") : should skip values without an href', () => { + const $ = load('example1'); + expect($('#1').prop('href')).toBeUndefined(); + }); + it('("src") : should resolve links with `baseURI`', () => { const $ = load( ` @@ -353,6 +358,13 @@ describe('$(...)', () => { expect($(undefined).prop('outerHTML')).toBeUndefined(); }); + it('("outerHTML") : should support root nodes', () => { + const $ = load('
'); + expect($.root().prop('outerHTML')).toBe( + '', + ); + }); + it('("innerHTML") : should render properly', () => { const $a = $(''); diff --git a/src/api/extract.spec.ts b/src/api/extract.spec.ts index b243212710..943b0825f4 100644 --- a/src/api/extract.spec.ts +++ b/src/api/extract.spec.ts @@ -118,4 +118,11 @@ describe('$.extract', () => { }, }); }); + + it('() : should not error on missing href prop (#4239)', () => { + const $ = load(fixtures.eleven); + expect<{ links: string[] }>( + $.extract({ links: [{ selector: 'li', value: 'href' }] }), + ).toStrictEqual({ links: [] }); + }); });