Skip to content

Commit

Permalink
fix(stats): fixed eslint and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MahtabBukhari committed Oct 22, 2024
1 parent 1431594 commit 4f636f4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/Stats/__tests__/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable padding-line-between-statements */
import '@testing-library/jest-dom'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import { render, screen, waitFor } from '@testing-library/react'
import React from 'react'
import { ProcessingResponse, getTotalProcessing } from '~/network/fetchSourcesData'
import { Stats } from '..'
Expand Down Expand Up @@ -37,7 +37,7 @@ const mockedUseUserStore = useUserStore as jest.MockedFunction<typeof useUserSto
const mockStats = {
audio_count: '1,000',
contributors_count: '500',
daily_count: '100',
daily_count: '200',
episodes_count: '2,000',
node_sount: '5,000',
twitter_spaceCount: '300',
Expand Down Expand Up @@ -143,10 +143,13 @@ describe('Component Test Stats', () => {
totalProcessing: 0,
}

// Now, simulate a response where totalProcessing is not present or is 0
mockedGetTotalProcessing.mockResolvedValueOnce(mockResponse)

// Re-render the component to reflect the new mock response
render(<Stats />)

// The button should not be visible since totalProcessing is equal to 0
const viewContent = screen.queryByTestId('view-content')
expect(viewContent).toBeNull()

Expand All @@ -156,12 +159,15 @@ describe('Component Test Stats', () => {
totalProcessing: 100,
}

// Mocking a response where totalProcessing is present and greater than 0
mockedGetTotalProcessing.mockResolvedValueOnce(mockResponse2)

render(<Stats />)

// Wait for the component to finish loading
await screen.findByTestId('view-content')

// The button should be visible since totalProcessing is present and greater than 0
const button = screen.getByText('100')
expect(button).toBeInTheDocument()
})
Expand Down

0 comments on commit 4f636f4

Please sign in to comment.