Skip to content

Commit

Permalink
test(app): Add initial test for app
Browse files Browse the repository at this point in the history
  • Loading branch information
robdmoore committed Mar 24, 2023
1 parent d190f6a commit 9edb232
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/app.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { describe, test } from '@jest/globals'
import algosdk from 'algosdk'
import { getBareCallContractData } from '../tests/example-contracts/bare-call/contract'
import * as algokit from './'
import { algoKitLogCaptureFixture, algorandFixture } from './testing'

describe('app', () => {
const localnet = algorandFixture()
beforeEach(localnet.beforeEach, 10_000)

const logging = algoKitLogCaptureFixture()
beforeEach(logging.beforeEach)
afterEach(logging.afterEach)

test('createApp creates an app', async () => {
const { algod, testAccount } = localnet.context
const contract = await getBareCallContractData()

const app = await algokit.createApp(
{
approvalProgram: contract.approvalProgram.replace('TMPL_UPDATABLE', '0').replace('TMPL_DELETABLE', '0').replace('TMPL_VALUE', '1'),
clearStateProgram: contract.clearStateProgram,
schema: contract.stateSchema,
from: testAccount,
},
algod,
)

expect(app.appId).toBeGreaterThan(0)
expect(app.appAddress).toBe(algosdk.getApplicationAddress(app.appId))
expect(app.confirmation).toBeTruthy()
expect(app.confirmation?.['application-index']).toBe(app.appId)
})
})

0 comments on commit 9edb232

Please sign in to comment.