From 1e4e41018590724f677f1debf226e2858aa2c57f Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Thu, 4 Jun 2026 16:33:36 +0900 Subject: [PATCH] test: add coverage outside SEA Signed-off-by: Daijiro Wachi --- test/parallel/test-sea-assets-not-in-sea.js | 37 +++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/parallel/test-sea-assets-not-in-sea.js diff --git a/test/parallel/test-sea-assets-not-in-sea.js b/test/parallel/test-sea-assets-not-in-sea.js new file mode 100644 index 00000000000000..957c452f44ad8a --- /dev/null +++ b/test/parallel/test-sea-assets-not-in-sea.js @@ -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);