mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
test: add coverage outside SEA
Signed-off-by: Daijiro Wachi <daijiro.wachi@gmail.com> PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
1 parent
af1a11e0dd
commit
6bd07df2bc
1 file changed
+37
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
|
||||
const { getRawAsset, getAsset, getAssetAsBlob } = require('node:sea');
|
||||
const assert = require('node:assert');
|
||||
|
||||
const invalidKeyArgs = [1, 1n, Symbol(), false, null, undefined, {}, []];
|
||||
const notInSeaError = {
|
||||
code: 'ERR_NOT_IN_SINGLE_EXECUTABLE_APPLICATION',
|
||||
name: 'Error',
|
||||
};
|
||||
|
||||
// getRawAsset
|
||||
for (const arg of invalidKeyArgs) {
|
||||
assert.throws(() => getRawAsset(arg), { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
|
||||
}
|
||||
assert.throws(() => getRawAsset('foo'), notInSeaError);
|
||||
|
||||
// getAsset
|
||||
for (const arg of invalidKeyArgs) {
|
||||
assert.throws(() => getAsset(arg), { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
|
||||
}
|
||||
for (const arg of [1, 1n, Symbol(), false, null, {}, []]) {
|
||||
assert.throws(() => getAsset('foo', arg), { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
|
||||
}
|
||||
assert.throws(() => getAsset('foo'), notInSeaError);
|
||||
assert.throws(() => getAsset('foo', 'utf8'), notInSeaError);
|
||||
assert.throws(() => getAsset('foo', undefined), notInSeaError);
|
||||
|
||||
// getAssetAsBlob
|
||||
for (const arg of invalidKeyArgs) {
|
||||
assert.throws(() => getAssetAsBlob(arg), { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
|
||||
}
|
||||
assert.throws(() => getAssetAsBlob('foo'), notInSeaError);
|
||||
assert.throws(() => getAssetAsBlob('foo', {}), notInSeaError);
|
||||
assert.throws(() => getAssetAsBlob('foo', { type: 'text/plain' }), notInSeaError);
|
||||
Reference in new issue
Block a user