Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit Test for Updated MarketCapResolver #594

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

icemedia001
Copy link
Contributor

@icemedia001 icemedia001 commented Oct 17, 2024

Unit Test for Updated MarketCapResolver

Unit tests for the methods in marketCap.resolver.ts which includes the linkWikiToRankData, using mocks for dependencies to ensure the resolver's logic is tested independently and to ensure the data is updated and that on refresh we also see the updated value.

pnpm test marketCap.resolver.tspec.ts

closes EveripediaNetwork/issues#3243
And
closes EveripediaNetwork/issues#3291

Copy link

stackblitz bot commented Oct 17, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

})

describe('rankPageIds', () => {
it('should update rank page ids', async () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

})

describe('linkWikiToRankData', () => {
it('should link wiki to rank data with valid wikiId', async () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

})

describe('rankPageIds', () => {
it('should update rank page ids', async () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

})

describe('linkWikiToRankData', () => {
it('should link wiki to rank data with valid wikiId', async () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

Copy link

codeclimate bot commented Oct 22, 2024

Code Climate has analyzed commit 389bc19 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2

View more on Code Climate.

Comment on lines +101 to +118
describe('linkWikiToRankData', () => {
it('should link wiki to rank data with valid wikiId', async () => {
const mockArgs: RankPageIdInputs = {
coingeckoId: 'iqcoin',
wikiId: 'wiki1',
kind: RankType.TOKEN,
}
;(mockMarketCapService.updateMistachIds as jest.Mock).mockResolvedValue(
true,
)

const result = await marketCapResolver.linkWikiToRankData(mockArgs)

expect(result).toBe(true)
expect(mockMarketCapService.updateMistachIds).toHaveBeenCalledWith(
mockArgs,
)
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test, we can also test that the update was successful by checking the updated cache for the changed value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test linkWikiToRankpage API Unit Test for Updated MarketCapResolver
2 participants