UNPKG

@cloudflare/puppeteer

Version:

Puppeteer fork for Cloudflare Browser Run (formerly Browser Rendering)

56 lines 3.1 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); /** * @license * Copyright 2024 Google Inc. * SPDX-License-Identifier: Apache-2.0 */ const node_test_1 = require("node:test"); const expect_1 = __importDefault(require("expect")); const HTTPRequest_js_1 = require("./HTTPRequest.js"); (0, node_test_1.describe)('HTTPRequest', () => { (0, node_test_1.describe)('getResponse', () => { (0, node_test_1.it)('should get body length from empty string', async () => { const response = HTTPRequest_js_1.HTTPRequest.getResponse(''); (0, expect_1.default)(response.contentLength).toBe(Buffer.from('').byteLength); }); (0, node_test_1.it)('should get body length from latin string', async () => { const body = 'Lorem ipsum dolor sit amet'; const response = HTTPRequest_js_1.HTTPRequest.getResponse(body); (0, expect_1.default)(response.contentLength).toBe(Buffer.from(body).byteLength); }); (0, node_test_1.it)('should get body length from string with emoji', async () => { const body = 'How Long is this string in bytes 📏?'; const response = HTTPRequest_js_1.HTTPRequest.getResponse(body); (0, expect_1.default)(response.contentLength).toBe(Buffer.from(body).byteLength); }); (0, node_test_1.it)('should get body length from Uint8Array', async () => { const body = Buffer.from('How Long is this string in bytes 📏?'); const response = HTTPRequest_js_1.HTTPRequest.getResponse(body); (0, expect_1.default)(response.contentLength).toBe(body.byteLength); }); (0, node_test_1.it)('should get base64 from empty string', async () => { const response = HTTPRequest_js_1.HTTPRequest.getResponse(''); (0, expect_1.default)(response.base64).toBe(Buffer.from('').toString('base64')); }); (0, node_test_1.it)('should get base64 from latin string', async () => { const body = 'Lorem ipsum dolor sit amet'; const response = HTTPRequest_js_1.HTTPRequest.getResponse(body); (0, expect_1.default)(response.base64).toBe(Buffer.from(body).toString('base64')); }); (0, node_test_1.it)('should get base64 from string with emoji', async () => { const body = 'What am I in base64 🤔?'; const response = HTTPRequest_js_1.HTTPRequest.getResponse(body); (0, expect_1.default)(response.base64).toBe(Buffer.from(body).toString('base64')); }); (0, node_test_1.it)('should get base64 length from Uint8Array', async () => { const body = Buffer.from('What am I in base64 🤔?'); const response = HTTPRequest_js_1.HTTPRequest.getResponse(body); (0, expect_1.default)(response.base64).toBe(body.toString('base64')); }); }); }); //# sourceMappingURL=HTTPRequest.test.js.map