import { describe, it, expect, afterEach } from 'vitest'; import * as cheerio from './index.js'; import { Writable } from 'node:stream'; import { createServer, type Server } from 'node:http'; function noop() { // Ignore } // Returns a promise and a resolve function function getPromise() { let cb: (error: Error | null | undefined, $: cheerio.CheerioAPI) => void; const promise = new Promise((resolve, reject) => { cb = (error, $) => (error ? reject(error) : resolve($)); }); return { promise, cb: cb! }; } const TEST_HTML = '

Hello World

'; const TEST_HTML_UTF16 = Buffer.from(TEST_HTML, 'utf16le'); const TEST_HTML_UTF16_BOM = Buffer.from([ // UTF16-LE BOM 0xff, 0xfe, ...Array.from(TEST_HTML_UTF16), ]); describe('loadBuffer', () => { it('should parse UTF-8 HTML', () => { const $ = cheerio.loadBuffer(Buffer.from(TEST_HTML)); expect($.html()).toBe( `${TEST_HTML}