Skip to content

Commit

Permalink
test: add tests for use list hook
Browse files Browse the repository at this point in the history
  • Loading branch information
eoaksnes committed Oct 27, 2023
1 parent 48e4e91 commit 599afe7
Show file tree
Hide file tree
Showing 7 changed files with 512 additions and 49 deletions.
14 changes: 0 additions & 14 deletions packages/dm-core-plugins/src/list/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,6 @@ export const SaveButton = (props: {
</Button>
)

export const ReloadButton = (props: {
onClick: (event: MouseEvent<HTMLButtonElement>) => void
disabled: boolean
isLoading: boolean
}) => (
<Button
disabled={props.disabled}
onClick={props.onClick}
data-testid="ReloadData"
>
{props.isLoading ? <Progress.Dots color={'primary'} /> : 'Undo'}
</Button>
)

export const ListItemButton = (props: {
onClick: () => void
disabled?: boolean
Expand Down
13 changes: 1 addition & 12 deletions packages/dm-core-plugins/src/list/ListPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ import {
} from '@development-framework/dm-core'
import { toast } from 'react-toastify'
import { Button, Icon, Tooltip, Typography } from '@equinor/eds-core-react'
import {
AppendButton,
ListItemButton,
ReloadButton,
SaveButton,
} from './Components'
import { AppendButton, ListItemButton, SaveButton } from './Components'
import { add, link, minimize } from '@equinor/eds-icons'

type TListConfig = {
Expand Down Expand Up @@ -69,7 +64,6 @@ export const ListPlugin = (props: IUIPlugin & { config?: TListConfig }) => {
removeItem,
save,
moveItem,
reloadData,
} = useList<TGenericObject>(idReference, internalConfig.resolveReferences)

const [paginationPage, setPaginationPage] = useState(0)
Expand Down Expand Up @@ -263,11 +257,6 @@ export const ListPlugin = (props: IUIPlugin & { config?: TListConfig }) => {
disabled={!dirtyState}
isLoading={isLoading}
/>
<ReloadButton
onClick={reloadData}
disabled={!dirtyState}
isLoading={isLoading}
/>
</Stack>
</Stack>
</Stack>
Expand Down
1 change: 1 addition & 0 deletions packages/dm-core/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const packageJson = require('./package.json')
const base = require('../../jest.config.base')

module.exports = {
...base,
testEnvironment: 'jsdom',
Expand Down
4 changes: 3 additions & 1 deletion packages/dm-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"luxon": "^3.4.3",
"react-icons": "4.10.1",
"react-oauth2-code-pkce": "^1.10.1",
"react-toastify": "^9.1.3"
"react-toastify": "^9.1.3",
"uuid": "^9.0.1"
},
"devDependencies": {
"@testing-library/react": "^14.0.0",
Expand All @@ -26,6 +27,7 @@
"@types/react-dom": "^18.2.7",
"@types/react-router-dom": "^5.3.3",
"@types/styled-components": "^5.1.26",
"@types/uuid": "^9.0.6",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"eslint-plugin-react": "^7.33.2",
Expand Down
Loading

0 comments on commit 599afe7

Please sign in to comment.