Skip to content

Commit

Permalink
feat: #1125: Update tests for components using react-redux hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
nphivu414 committed May 13, 2020
1 parent 49fabe7 commit 11bfa62
Show file tree
Hide file tree
Showing 31 changed files with 4,406 additions and 448 deletions.
30 changes: 15 additions & 15 deletions packages/marketplace/src/actions/__tests__/client.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import {
clientAppSummaryRequestData,
clientAppSummaryReceiveData,
clientAppSummaryRequestDataFailure,
clientAppSummaryClearData,
clientFetchAppSummary,
clientFetchAppSummarySuccess,
clientFetchAppSummaryFailed,
clientClearAppSummary,
} from '../client'
import ActionTypes from '../../constants/action-types'
import { appsDataStub, featuredAppsDataStub } from '../../sagas/__stubs__/apps'

describe('client actions', () => {
it('should create a clientAppSummaryRequestData action', () => {
expect(clientAppSummaryRequestData.type).toEqual(ActionTypes.CLIENT_APP_SUMMARY_REQUEST_DATA)
expect(clientAppSummaryRequestData({ page: 1 }).data).toEqual({ page: 1 })
it('should create a clientFetchAppSummary action', () => {
expect(clientFetchAppSummary.type).toEqual(ActionTypes.CLIENT_FETCH_APP_SUMMARY)
expect(clientFetchAppSummary({ page: 1 }).data).toEqual({ page: 1 })
})
it('should create a clientAppSummaryReceiveData action', () => {
expect(clientAppSummaryReceiveData.type).toEqual(ActionTypes.CLIENT_APP_SUMMARY_RECEIVE_DATA)
it('should create a clientFetchAppSummarySuccess action', () => {
expect(clientFetchAppSummarySuccess.type).toEqual(ActionTypes.CLIENT_FETCH_APP_SUMMARY_SUCCESS)
expect(
clientAppSummaryReceiveData({ featuredApps: featuredAppsDataStub.data.data, apps: appsDataStub.data }).data,
clientFetchAppSummarySuccess({ featuredApps: featuredAppsDataStub.data.data, apps: appsDataStub.data }).data,
).toEqual({
featuredApps: featuredAppsDataStub.data.data,
apps: appsDataStub.data,
})
})
it('should create a clientAppSummaryRequestDataFailure action', () => {
expect(clientAppSummaryRequestDataFailure.type).toEqual(ActionTypes.CLIENT_APP_SUMMARY_REQUEST_FAILURE)
expect(clientAppSummaryRequestDataFailure('error').data).toEqual('error')
it('should create a clientFetchAppSummaryFailed action', () => {
expect(clientFetchAppSummaryFailed.type).toEqual(ActionTypes.CLIENT_FETCH_APP_SUMMARY_FAILED)
expect(clientFetchAppSummaryFailed('error').data).toEqual('error')
})
it('should create a clientClearData action', () => {
expect(clientAppSummaryClearData.type).toEqual(ActionTypes.CLIENT_APP_SUMMARY_CLEAR_DATA)
expect(clientAppSummaryClearData(null).data).toEqual(null)
expect(clientClearAppSummary.type).toEqual(ActionTypes.CLIENT_CLEAR_APP_SUMMARY)
expect(clientClearAppSummary(null).data).toEqual(null)
})
})
12 changes: 5 additions & 7 deletions packages/marketplace/src/actions/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import { ClientAppSummary, ClientAppSummaryParams } from '../reducers/client/app
import { AppDetailData } from '@/reducers/client/app-detail'
import { FetchAppDetailParams } from '@/services/apps'

export const clientAppSummaryRequestData = actionCreator<ClientAppSummaryParams>(
ActionTypes.CLIENT_APP_SUMMARY_REQUEST_DATA,
export const clientFetchAppSummary = actionCreator<ClientAppSummaryParams>(ActionTypes.CLIENT_FETCH_APP_SUMMARY)
export const clientFetchAppSummarySuccess = actionCreator<ClientAppSummary | undefined>(
ActionTypes.CLIENT_FETCH_APP_SUMMARY_SUCCESS,
)
export const clientAppSummaryReceiveData = actionCreator<ClientAppSummary | undefined>(
ActionTypes.CLIENT_APP_SUMMARY_RECEIVE_DATA,
)
export const clientAppSummaryRequestDataFailure = actionCreator<string>(ActionTypes.CLIENT_APP_SUMMARY_REQUEST_FAILURE)
export const clientAppSummaryClearData = actionCreator<null>(ActionTypes.CLIENT_APP_SUMMARY_CLEAR_DATA)
export const clientFetchAppSummaryFailed = actionCreator<string>(ActionTypes.CLIENT_FETCH_APP_SUMMARY_FAILED)
export const clientClearAppSummary = actionCreator<null>(ActionTypes.CLIENT_CLEAR_APP_SUMMARY)

// Client App Detail
export const clientFetchAppDetail = actionCreator<FetchAppDetailParams>(ActionTypes.CLIENT_FETCH_APP_DETAIL)
Expand Down
Loading

0 comments on commit 11bfa62

Please sign in to comment.