From 9ad96059379aba96af60e6465186512002911400 Mon Sep 17 00:00:00 2001 From: Richard Walker Date: Thu, 10 Oct 2024 16:39:24 +1300 Subject: [PATCH] test: verify that headers are sent before body --- tests/podlet.test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/podlet.test.js b/tests/podlet.test.js index 01c45ff..dab7d5b 100644 --- a/tests/podlet.test.js +++ b/tests/podlet.test.js @@ -2019,7 +2019,7 @@ tap.test( tap.test( 'assets - .js() and .css() - Link headers - should be sent before body', async (t) => { - t.plan(3); + t.plan(4); const podlet = new Podlet({ name: 'foo', version: 'v1.0.0', @@ -2046,6 +2046,7 @@ tap.test( }); await server.listen(); + let start = 0; const result = await server.get({ raw: true, onHeaders(headers) { @@ -2054,11 +2055,14 @@ tap.test( '; async=true; type=module; data-foo=bar; scope=content; asset-type=script, ; type=text/css; rel=stylesheet; scope=content; asset-type=style', ); orderArray.push('assets'); + start = Date.now(); }, }); + const timeTaken = Date.now() - start; orderArray.push('body'); t.match(result.response, /

OK!<\/h1>/); t.same(orderArray, ['assets', 'body']); + t.ok(timeTaken > 900); await server.close(); }, );