From d75cf95b3802c5f42765433468d0f453121318c5 Mon Sep 17 00:00:00 2001 From: Kohei Ueno Date: Fri, 8 Jul 2022 17:12:22 +0900 Subject: [PATCH] test: improve code coverage for performance_entry PR-URL: https://github.com/nodejs/node/pull/43434 Reviewed-By: Luigi Pinca Reviewed-By: Darshan Sen Reviewed-By: James M Snell --- .../test-perf-hooks-resourcetiming.js | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/parallel/test-perf-hooks-resourcetiming.js b/test/parallel/test-perf-hooks-resourcetiming.js index bf4b49347bb289..056924c4eb8c6f 100644 --- a/test/parallel/test-perf-hooks-resourcetiming.js +++ b/test/parallel/test-perf-hooks-resourcetiming.js @@ -2,6 +2,7 @@ const common = require('../common'); const assert = require('assert'); +const util = require('util'); const { PerformanceObserver, PerformanceEntry, @@ -14,6 +15,7 @@ const { assert(PerformanceObserver); assert(PerformanceEntry); +assert.throws(() => new PerformanceEntry(), { code: 'ERR_ILLEGAL_CONSTRUCTOR' }); assert(PerformanceResourceTiming); assert(clearResourceTimings); assert(markResourceTiming); @@ -174,6 +176,54 @@ function createTimingInfo({ encodedBodySize: 0, decodedBodySize: 0, }); + assert.strictEqual(util.inspect(performance.getEntries()), `[ + PerformanceResourceTiming { + name: 'http://localhost:8080', + entryType: 'resource', + startTime: 0, + duration: 0, + initiatorType: 'fetch', + nextHopProtocol: [], + workerStart: 0, + redirectStart: 0, + redirectEnd: 0, + fetchStart: 0, + domainLookupStart: 0, + domainLookupEnd: 0, + connectStart: 0, + connectEnd: 0, + secureConnectionStart: 0, + requestStart: 0, + responseStart: 0, + responseEnd: 0, + transferSize: 0, + encodedBodySize: 0, + decodedBodySize: 0 + } +]`); + assert.strictEqual(util.inspect(resource), `PerformanceResourceTiming { + name: 'http://localhost:8080', + entryType: 'resource', + startTime: 0, + duration: 0, + initiatorType: 'fetch', + nextHopProtocol: [], + workerStart: 0, + redirectStart: 0, + redirectEnd: 0, + fetchStart: 0, + domainLookupStart: 0, + domainLookupEnd: 0, + connectStart: 0, + connectEnd: 0, + secureConnectionStart: 0, + requestStart: 0, + responseStart: 0, + responseEnd: 0, + transferSize: 0, + encodedBodySize: 0, + decodedBodySize: 0 +}`); assert(resource instanceof PerformanceEntry); assert(resource instanceof PerformanceResourceTiming);