Skip to content

Commit 6bd07df

Browse files
watildeaduh95
authored andcommitted
test: add coverage outside SEA
Signed-off-by: Daijiro Wachi <daijiro.wachi@gmail.com> PR-URL: #63744 Refs: https://app.codecov.io/gh/nodejs/node/blob/main/lib%2Fsea.js Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent af1a11e commit 6bd07df

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
require('../common');
4+
5+
const { getRawAsset, getAsset, getAssetAsBlob } = require('node:sea');
6+
const assert = require('node:assert');
7+
8+
const invalidKeyArgs = [1, 1n, Symbol(), false, null, undefined, {}, []];
9+
const notInSeaError = {
10+
code: 'ERR_NOT_IN_SINGLE_EXECUTABLE_APPLICATION',
11+
name: 'Error',
12+
};
13+
14+
// getRawAsset
15+
for (const arg of invalidKeyArgs) {
16+
assert.throws(() => getRawAsset(arg), { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
17+
}
18+
assert.throws(() => getRawAsset('foo'), notInSeaError);
19+
20+
// getAsset
21+
for (const arg of invalidKeyArgs) {
22+
assert.throws(() => getAsset(arg), { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
23+
}
24+
for (const arg of [1, 1n, Symbol(), false, null, {}, []]) {
25+
assert.throws(() => getAsset('foo', arg), { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
26+
}
27+
assert.throws(() => getAsset('foo'), notInSeaError);
28+
assert.throws(() => getAsset('foo', 'utf8'), notInSeaError);
29+
assert.throws(() => getAsset('foo', undefined), notInSeaError);
30+
31+
// getAssetAsBlob
32+
for (const arg of invalidKeyArgs) {
33+
assert.throws(() => getAssetAsBlob(arg), { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
34+
}
35+
assert.throws(() => getAssetAsBlob('foo'), notInSeaError);
36+
assert.throws(() => getAssetAsBlob('foo', {}), notInSeaError);
37+
assert.throws(() => getAssetAsBlob('foo', { type: 'text/plain' }), notInSeaError);

0 commit comments

Comments
 (0)