Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
Seroxdesign committed Jun 24, 2024
1 parent 3d65aea commit 630298b
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
40 changes: 40 additions & 0 deletions wallets/keplr/test/unit/prepareExtension.test.ts
Original file line number Diff line number Diff line change
@@ -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()
})
})
7 changes: 7 additions & 0 deletions wallets/keplr/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
dir: 'test/unit'
}
})
40 changes: 40 additions & 0 deletions wallets/metamask/test/unit/prepareExtension.test.ts
Original file line number Diff line number Diff line change
@@ -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()
})
})
7 changes: 7 additions & 0 deletions wallets/metamask/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
dir: 'test/unit'
}
})

0 comments on commit 630298b

Please sign in to comment.