Skip to content

Commit

Permalink
test: verify that headers are sent before body
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalsadhu committed Oct 10, 2024
1 parent 815ea97 commit 9ad9605
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/podlet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -2046,6 +2046,7 @@ tap.test(
});

await server.listen();
let start = 0;
const result = await server.get({
raw: true,
onHeaders(headers) {
Expand All @@ -2054,11 +2055,14 @@ tap.test(
'</scripts.js>; async=true; type=module; data-foo=bar; scope=content; asset-type=script, </styles.css>; 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, /<h1>OK!<\/h1>/);
t.same(orderArray, ['assets', 'body']);
t.ok(timeTaken > 900);
await server.close();
},
);
Expand Down

0 comments on commit 9ad9605

Please sign in to comment.