Skip to content

Commit cb8c848

Browse files
author
iyashragrawal
committed
feat: add more unit tests to simple collectiosn dev kit
1 parent c18e257 commit cb8c848

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

lib/ethereum/simpleCollection/description.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,37 @@ describe('description.spec.ts', () => {
3535
const result = await caller(id, address, stakingPositions, rewards, keys)
3636
expect(result).toEqual(expected)
3737
})
38+
39+
it('call failure', async () => {
40+
const error = 'error'
41+
42+
const id = 1
43+
const address = ''
44+
const stakingPositions = {
45+
property: '0x0000000000000000000000000000000000000000',
46+
amount: '0',
47+
price: '0',
48+
cumulativeReward: '0',
49+
pendingReward: '0'
50+
}
51+
const rewards = {
52+
entireReward: '0',
53+
cumulativeReward: '0',
54+
withdrawableReward: '0'
55+
}
56+
const keys = ['0x000']
57+
const devContract = {
58+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
59+
description: jest
60+
.fn()
61+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
62+
.mockImplementation(async (id: number, address: string, stakingPositions: StakingPosition, rewards: Rewards, keys: readonly string[]) => Promise.reject(error)),
63+
}
64+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
65+
const caller = createQueryCaller(devContract as any, 'description')
66+
const result = await caller(id, address, stakingPositions, rewards, keys).catch((err) => err)
67+
68+
expect(result).toEqual(error)
69+
})
3870
})
3971
})

lib/ethereum/simpleCollection/image.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,37 @@ describe('image.spec.ts', () => {
3535
const result = await caller(id, address, stakingPositions, rewards, keys)
3636
expect(result).toEqual(expected)
3737
})
38+
39+
it('call failure', async () => {
40+
const error = 'error'
41+
42+
const id = 1
43+
const address = ''
44+
const stakingPositions = {
45+
property: '0x0000000000000000000000000000000000000000',
46+
amount: '0',
47+
price: '0',
48+
cumulativeReward: '0',
49+
pendingReward: '0'
50+
}
51+
const rewards = {
52+
entireReward: '0',
53+
cumulativeReward: '0',
54+
withdrawableReward: '0'
55+
}
56+
const keys = ['0x000']
57+
const devContract = {
58+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
59+
image: jest
60+
.fn()
61+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
62+
.mockImplementation(async (id: number, address: string, stakingPositions: StakingPosition, rewards: Rewards, keys: readonly string[]) => Promise.reject(error)),
63+
}
64+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
65+
const caller = createQueryCaller(devContract as any, 'image')
66+
const result = await caller(id, address, stakingPositions, rewards, keys).catch((err) => err)
67+
68+
expect(result).toEqual(error)
69+
})
3870
})
3971
})

lib/ethereum/simpleCollection/name.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,37 @@ describe('name.spec.ts', () => {
3535
const result = await caller(id, address, stakingPositions, rewards, keys)
3636
expect(result).toEqual(expected)
3737
})
38+
39+
it('call failure', async () => {
40+
const error = 'error'
41+
42+
const id = 1
43+
const address = ''
44+
const stakingPositions = {
45+
property: '0x0000000000000000000000000000000000000000',
46+
amount: '0',
47+
price: '0',
48+
cumulativeReward: '0',
49+
pendingReward: '0'
50+
}
51+
const rewards = {
52+
entireReward: '0',
53+
cumulativeReward: '0',
54+
withdrawableReward: '0'
55+
}
56+
const keys = ['0x000']
57+
const devContract = {
58+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
59+
name: jest
60+
.fn()
61+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
62+
.mockImplementation(async (id: number, address: string, stakingPositions: StakingPosition, rewards: Rewards, keys: readonly string[]) => Promise.reject(error)),
63+
}
64+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
65+
const caller = createQueryCaller(devContract as any, 'name')
66+
const result = await caller(id, address, stakingPositions, rewards, keys).catch((err) => err)
67+
68+
expect(result).toEqual(error)
69+
})
3870
})
3971
})

0 commit comments

Comments
 (0)