| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 38758a7 commit d59d7fd
1 file changed
| Original file line number | Diff line number | Diff 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); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments