Skip to content

Commit

Permalink
feature: #1917 Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vu Nguyen committed Jul 9, 2020
1 parent 0a6d78e commit c575c89
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from '@reapit/elements'
import { selectAdminAppsData, selectAdminAppsLoading } from '@/selector/admin'
import { adminAppsRequestFeatured } from '@/actions/admin-apps'
import AppDeleteModal from '@/components/pages/app-detail/app-delete'
import AppDeleteModal from '@/components/pages/app-detail/app-delete-modal'
import { addQuery, stringifyObjectIntoQueryString, getParamsFromPath } from '@/utils/client-url-params'
import { cleanObject } from '@reapit/utils'
import Routes from '@/constants/routes'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import * as ReactRedux from 'react-redux'
import { mount } from 'enzyme'
import configureStore from 'redux-mock-store'
import appState from '@/reducers/__stubs__/app-state'
import { DeleteAppModal, AppDeleteProps, handleAfterClose, onDeleteButtonClick, handleUseEffect } from '../app-delete'
import {
DeleteAppModal,
AppDeleteProps,
handleAfterClose,
onDeleteButtonClick,
handleUseEffect,
} from '../app-delete-modal'
import { appDeleteRequest } from '@/actions/app-delete'
import { appDeleteSetInitFormState } from '@/actions/app-delete'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DeveloperAppDetailState } from '@/reducers/developer'
import {
onAppDeleteModalAfterClose,
onDeleteSuccess,
onDeveloperAppRevisionModalAfterClose,
onAppRevisionModalAfterClose,
onPendingRevisionButtonClick,
onEditDetailButtonClick,
onDeleteAppButtonClick,
Expand Down Expand Up @@ -72,10 +72,10 @@ describe('ManageApp', () => {
})
})

describe('onDeveloperAppRevisionModalAfterClose', () => {
describe('onAppRevisionModalAfterClose', () => {
it('should be called correctly', () => {
const mockFunction = jest.fn()
const fn = onDeveloperAppRevisionModalAfterClose(mockFunction)
const fn = onAppRevisionModalAfterClose(mockFunction)
fn()
expect(mockFunction).toBeCalledWith(false)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react'
import { DeveloperAppDetailState } from '@/reducers/developer'
import { useDispatch, useSelector } from 'react-redux'
import { selectClientId } from '@/selector/client'
import DeveloperAppRevisionModal from './app-revision-modal'
import AppDelete from '@/components/pages/app-detail/app-delete'
import AppRevisionModal from './app-revision-modal'
import AppDeleteModal from '@/components/pages/app-detail/app-delete-modal'
import { Content, Button } from '@reapit/elements'
import { useHistory } from 'react-router'
import routes from '@/constants/routes'
Expand All @@ -12,7 +12,7 @@ import { Dispatch } from 'redux'
import { developerFetchAppDetail } from '@/actions/developer'
import styles from '@/styles/blocks/standalone-app-detail.scss?mod'

interface ManageAppProps {
interface AppManagementProps {
pendingRevisions: boolean
appDetailState: DeveloperAppDetailState
id: string
Expand All @@ -38,7 +38,7 @@ export const onCancelSuccess = ({
dispatch(developerFetchAppDetail({ id, clientId }))
}

export const onDeveloperAppRevisionModalAfterClose = (setVisible: (value: boolean) => void) => () => {
export const onAppRevisionModalAfterClose = (setVisible: (value: boolean) => void) => () => {
setVisible(false)
}

Expand All @@ -54,7 +54,7 @@ export const onDeleteAppButtonClick = (setVisible: (value: boolean) => void) =>
setVisible(true)
}

export const ManageApp: React.FC<ManageAppProps> = ({ pendingRevisions, id, appDetailState }) => {
export const AppManagement: React.FC<AppManagementProps> = ({ pendingRevisions, id, appDetailState }) => {
const [isDeleteModalOpen, setIsDeleteModalOpen] = React.useState(false)
const [isAppRevisionComparisonModalOpen, setIsAppRevisionComparisonModalOpen] = React.useState(false)
const { buttonGroup } = styles
Expand All @@ -66,7 +66,7 @@ export const ManageApp: React.FC<ManageAppProps> = ({ pendingRevisions, id, appD
return (
<Content className={buttonGroup}>
{isDeleteModalOpen && (
<AppDelete
<AppDeleteModal
appId={id || ''}
appName={appDetailState?.data?.name || ''}
afterClose={onAppDeleteModalAfterClose(setIsDeleteModalOpen)}
Expand All @@ -76,7 +76,7 @@ export const ManageApp: React.FC<ManageAppProps> = ({ pendingRevisions, id, appD
)}

{isAppRevisionComparisonModalOpen && (
<DeveloperAppRevisionModal
<AppRevisionModal
onCancelSuccess={onCancelSuccess({
dispatch,
clientId,
Expand All @@ -85,7 +85,7 @@ export const ManageApp: React.FC<ManageAppProps> = ({ pendingRevisions, id, appD
appDetailState={appDetailState}
visible={isAppRevisionComparisonModalOpen}
appId={id || ''}
afterClose={onDeveloperAppRevisionModalAfterClose(setIsAppRevisionComparisonModalOpen)}
afterClose={onAppRevisionModalAfterClose(setIsAppRevisionComparisonModalOpen)}
/>
)}

Expand Down Expand Up @@ -120,4 +120,4 @@ export const ManageApp: React.FC<ManageAppProps> = ({ pendingRevisions, id, appD
)
}

export default ManageApp
export default AppManagement
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AppInstallationsModal should match a snapshot 1`] = `
<Component
afterClose={[MockFunction]}
renderChildren={true}
visible={true}
/>
`;

0 comments on commit c575c89

Please sign in to comment.