11cb0ef41Sopenharmony_ciimport * as common from '../common/index.mjs';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciimport assert from 'assert';
41cb0ef41Sopenharmony_ciimport events from 'events';
51cb0ef41Sopenharmony_ciimport http from 'http';
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciassert.strictEqual(typeof globalThis.fetch, 'function');
81cb0ef41Sopenharmony_ciassert.strictEqual(typeof globalThis.FormData, 'function');
91cb0ef41Sopenharmony_ciassert.strictEqual(typeof globalThis.Headers, 'function');
101cb0ef41Sopenharmony_ciassert.strictEqual(typeof globalThis.Request, 'function');
111cb0ef41Sopenharmony_ciassert.strictEqual(typeof globalThis.Response, 'function');
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustCall((req, res) => {
141cb0ef41Sopenharmony_ci  res.end('Hello world');
151cb0ef41Sopenharmony_ci}));
161cb0ef41Sopenharmony_ciserver.listen(0);
171cb0ef41Sopenharmony_ciawait events.once(server, 'listening');
181cb0ef41Sopenharmony_ciconst port = server.address().port;
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ciconst response = await fetch(`http://localhost:${port}`);
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ciassert(response instanceof Response);
231cb0ef41Sopenharmony_ciassert.strictEqual(response.status, 200);
241cb0ef41Sopenharmony_ciassert.strictEqual(response.statusText, 'OK');
251cb0ef41Sopenharmony_ciconst body = await response.text();
261cb0ef41Sopenharmony_ciassert.strictEqual(body, 'Hello world');
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ciserver.close();
29