Skip to content

Commit c18e257

Browse files
author
iyashragrawal
committed
feat: add test cases for view functions of simple collection
1 parent 0647616 commit c18e257

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Rewards } from '../s-tokens/rewards'
2+
import { createQueryCaller } from './queryCaller'
3+
import { Positions as StakingPosition } from '../s-tokens'
4+
5+
describe('description.spec.ts', () => {
6+
describe('createQueryCaller:description', () => {
7+
it('call success', async () => {
8+
const value = "This is image description"
9+
10+
const id = 1
11+
const address = ''
12+
const stakingPositions = {
13+
property: '0x0000000000000000000000000000000000000000',
14+
amount: '0',
15+
price: '0',
16+
cumulativeReward: '0',
17+
pendingReward: '0'
18+
}
19+
const rewards = {
20+
entireReward: '0',
21+
cumulativeReward: '0',
22+
withdrawableReward: '0'
23+
}
24+
const keys = ['0x000']
25+
const devContract = {
26+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
27+
description: jest
28+
.fn()
29+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
30+
.mockImplementation(async (id: number, address: string, stakingPositions: StakingPosition, rewards: Rewards, keys: readonly string[]) => value),
31+
}
32+
const expected = value
33+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
34+
const caller = createQueryCaller(devContract as any, 'description')
35+
const result = await caller(id, address, stakingPositions, rewards, keys)
36+
expect(result).toEqual(expected)
37+
})
38+
})
39+
})
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Rewards } from '../s-tokens/rewards'
2+
import { createQueryCaller } from './queryCaller'
3+
import { Positions as StakingPosition } from '../s-tokens'
4+
5+
describe('image.spec.ts', () => {
6+
describe('createQueryCaller:image', () => {
7+
it('call success', async () => {
8+
const value = "This is image url"
9+
10+
const id = 1
11+
const address = ''
12+
const stakingPositions = {
13+
property: '0x0000000000000000000000000000000000000000',
14+
amount: '0',
15+
price: '0',
16+
cumulativeReward: '0',
17+
pendingReward: '0'
18+
}
19+
const rewards = {
20+
entireReward: '0',
21+
cumulativeReward: '0',
22+
withdrawableReward: '0'
23+
}
24+
const keys = ['0x000']
25+
const devContract = {
26+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
27+
image: jest
28+
.fn()
29+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
30+
.mockImplementation(async (id: number, address: string, stakingPositions: StakingPosition, rewards: Rewards, keys: readonly string[]) => value),
31+
}
32+
const expected = value
33+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
34+
const caller = createQueryCaller(devContract as any, 'image')
35+
const result = await caller(id, address, stakingPositions, rewards, keys)
36+
expect(result).toEqual(expected)
37+
})
38+
})
39+
})
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Rewards } from '../s-tokens/rewards'
2+
import { createQueryCaller } from './queryCaller'
3+
import { Positions as StakingPosition } from '../s-tokens'
4+
5+
describe('name.spec.ts', () => {
6+
describe('createQueryCaller:name', () => {
7+
it('call success', async () => {
8+
const value = "This is image name"
9+
10+
const id = 1
11+
const address = ''
12+
const stakingPositions = {
13+
property: '0x0000000000000000000000000000000000000000',
14+
amount: '0',
15+
price: '0',
16+
cumulativeReward: '0',
17+
pendingReward: '0'
18+
}
19+
const rewards = {
20+
entireReward: '0',
21+
cumulativeReward: '0',
22+
withdrawableReward: '0'
23+
}
24+
const keys = ['0x000']
25+
const devContract = {
26+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
27+
name: jest
28+
.fn()
29+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
30+
.mockImplementation(async (id: number, address: string, stakingPositions: StakingPosition, rewards: Rewards, keys: readonly string[]) => value),
31+
}
32+
const expected = value
33+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
34+
const caller = createQueryCaller(devContract as any, 'name')
35+
const result = await caller(id, address, stakingPositions, rewards, keys)
36+
expect(result).toEqual(expected)
37+
})
38+
})
39+
})

0 commit comments

Comments
 (0)