diff --git a/src/helper.ts b/src/helper.ts index 029f134..3b82b73 100644 --- a/src/helper.ts +++ b/src/helper.ts @@ -1,12 +1,11 @@ import unpack, { IWasmModule } from './unpack'; -import unpackWasm from './unpack.wasm'; const initializeWasm = async (wasmPath: string | undefined): Promise => { try { const wasmModule: IWasmModule = await unpack({ locateFile(path: string) { if (path.endsWith('.wasm')) { - return wasmPath ? wasmPath : unpackWasm; + return wasmPath ? wasmPath : 'unpack.wasm'; } return path; } @@ -17,4 +16,5 @@ const initializeWasm = async (wasmPath: string | undefined): Promise Promise; } -export const initUntarJS = async (wasmPath: string | undefined): Promise => { +export const initUntarJS = async (wasmPath?: string): Promise => { let wasmModule: IWasmModule | undefined = undefined; try { wasmModule = await initializeWasm(wasmPath); diff --git a/tests/index.spec.ts b/tests/index.spec.ts index a1259b2..7b0b272 100644 --- a/tests/index.spec.ts +++ b/tests/index.spec.ts @@ -1,4 +1,4 @@ -import untarjs from '../src/index'; +import { initUntarJS } from '../src/index'; jest.mock('../src/helper', () => ({ __esModule: true, @@ -14,6 +14,8 @@ jest.mock('../src/index', () => { describe('extract', () => { it('should download and extract data successfully', async () => { + const untarjs = await initUntarJS(); + const mockData = new Uint8Array([1, 2, 3, 4]); const extractedData = { data: new Uint8Array([5, 6, 7, 8]),