diff --git a/wallets/keplr/test/unit/prepareExtension.test.ts b/wallets/keplr/test/unit/prepareExtension.test.ts new file mode 100644 index 000000000..e8644cf50 --- /dev/null +++ b/wallets/keplr/test/unit/prepareExtension.test.ts @@ -0,0 +1,40 @@ +import { afterAll, afterEach, describe, expect, it, vi } from 'vitest' +import { prepareExtension } from '@synthetixio/synpress-cache' + +const MOCK_CACHE_DIR_PATH = 'mockCacheDirPath' +const MOCK_EXTENSION_FINAL_PATH = 'mockExtensionFinalPath' + +vi.mock('@synthetixio/synpress-cache', async (importOriginal) => { + const prep: { prepareExtension: () => void } = await importOriginal() + + return { + default: vi.fn(), + ensureCacheDirExists: vi.fn().mockImplementation(() => MOCK_CACHE_DIR_PATH), + downloadFile: vi.fn().mockImplementation(() => { + return { + filePath: 'mockExtensionArchivePath' + } + }), + unzipArchive: vi.fn().mockImplementation(() => { + return { + outputPath: MOCK_EXTENSION_FINAL_PATH + } + }), + prepareExtension: prep.prepareExtension + } +}) + +describe('prepareExtension', () => { + afterEach(() => { + vi.clearAllMocks() + }) + + afterAll(() => { + vi.resetAllMocks() + }) + + it('returns correct unzipped extension path', async () => { + const extensionPath = await prepareExtension('MetaMask') + expect(extensionPath).toBeDefined() + }) +}) \ No newline at end of file diff --git a/wallets/keplr/vitest.config.ts b/wallets/keplr/vitest.config.ts new file mode 100644 index 000000000..42ec65bf9 --- /dev/null +++ b/wallets/keplr/vitest.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + dir: 'test/unit' + } +}) diff --git a/wallets/metamask/test/unit/prepareExtension.test.ts b/wallets/metamask/test/unit/prepareExtension.test.ts new file mode 100644 index 000000000..e8644cf50 --- /dev/null +++ b/wallets/metamask/test/unit/prepareExtension.test.ts @@ -0,0 +1,40 @@ +import { afterAll, afterEach, describe, expect, it, vi } from 'vitest' +import { prepareExtension } from '@synthetixio/synpress-cache' + +const MOCK_CACHE_DIR_PATH = 'mockCacheDirPath' +const MOCK_EXTENSION_FINAL_PATH = 'mockExtensionFinalPath' + +vi.mock('@synthetixio/synpress-cache', async (importOriginal) => { + const prep: { prepareExtension: () => void } = await importOriginal() + + return { + default: vi.fn(), + ensureCacheDirExists: vi.fn().mockImplementation(() => MOCK_CACHE_DIR_PATH), + downloadFile: vi.fn().mockImplementation(() => { + return { + filePath: 'mockExtensionArchivePath' + } + }), + unzipArchive: vi.fn().mockImplementation(() => { + return { + outputPath: MOCK_EXTENSION_FINAL_PATH + } + }), + prepareExtension: prep.prepareExtension + } +}) + +describe('prepareExtension', () => { + afterEach(() => { + vi.clearAllMocks() + }) + + afterAll(() => { + vi.resetAllMocks() + }) + + it('returns correct unzipped extension path', async () => { + const extensionPath = await prepareExtension('MetaMask') + expect(extensionPath).toBeDefined() + }) +}) \ No newline at end of file diff --git a/wallets/metamask/vitest.config.ts b/wallets/metamask/vitest.config.ts new file mode 100644 index 000000000..42ec65bf9 --- /dev/null +++ b/wallets/metamask/vitest.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + dir: 'test/unit' + } +})