mirror of
https://github.com/cheeriojs/cheerio.git
synced 2026-02-25 23:25:17 +00:00
@@ -321,6 +321,11 @@ describe('$(...)', () => {
|
||||
expect($(undefined).prop('href')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('("href") : should skip values without an href', () => {
|
||||
const $ = load('<a id="1">example1</a>');
|
||||
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('<div></div>');
|
||||
expect($.root().prop('outerHTML')).toBe(
|
||||
'<html><head></head><body><div></div></body></html>',
|
||||
);
|
||||
});
|
||||
|
||||
it('("innerHTML") : should render properly', () => {
|
||||
const $a = $('<div><a></a></div>');
|
||||
|
||||
|
||||
@@ -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: [] });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user