Skip to content

Commit

Permalink
improve test files
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmgdr committed Nov 8, 2024
1 parent 208767f commit 1b73d98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 0 additions & 1 deletion packages/cli/proposalTransactions.json

This file was deleted.

12 changes: 9 additions & 3 deletions packages/cli/src/commands/governance/build-proposals.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import CeloTokenABI from '@celo/abis/GoldToken.json'
import { testWithAnvilL2 } from '@celo/dev-utils/lib/anvil-test'
import { readJSON } from 'fs-extra'
import { readJSON, removeSync } from 'fs-extra'
import inquirer from 'inquirer'
import Web3 from 'web3'
import { testLocallyWithWeb3Node } from '../../test-utils/cliUtils'
Expand All @@ -10,6 +10,8 @@ process.env.NO_SYNCCHECK = 'true'

jest.mock('inquirer')

const TX_PATH_FOR_TEST = './test-tx.json'

testWithAnvilL2('governance:build-proposal cmd', (web3: Web3) => {
describe('building proposal to transfer funds from governance', () => {
beforeEach(async () => {
Expand All @@ -34,8 +36,8 @@ testWithAnvilL2('governance:build-proposal cmd', (web3: Web3) => {
promptSpy.mockResolvedValueOnce({ 'Celo Contract': '✔ done' })
})
it('generates the json', async () => {
await testLocallyWithWeb3Node(BuildProposal, ['--output', './transactions.json'], web3)
const result = await readJSON('./transactions.json')
await testLocallyWithWeb3Node(BuildProposal, ['--output', TX_PATH_FOR_TEST], web3)
const result = await readJSON(TX_PATH_FOR_TEST)
expect(result).toMatchInlineSnapshot(`
[
{
Expand All @@ -51,4 +53,8 @@ testWithAnvilL2('governance:build-proposal cmd', (web3: Web3) => {
`)
})
})
afterAll(() => {
jest.restoreAllMocks()
removeSync(TX_PATH_FOR_TEST)
})
})

0 comments on commit 1b73d98

Please sign in to comment.