Skip to content

Commit

Permalink
reference helper
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanad94 committed Nov 20, 2023
1 parent 40489c1 commit 59e0252
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions packages/sn-pickers-react/tests/picker.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Checkbox, IconButton, Link, ListItem, ListItemText, TextField } from '@material-ui/core'
import { mount } from 'enzyme'
import { mount, shallow } from 'enzyme'
import React from 'react'
import { act } from 'react-dom/test-utils'
import { SearchPicker, SelectionList, TreePicker } from '../src'
Expand Down Expand Up @@ -480,7 +480,7 @@ describe('Picker component', () => {
expect(
wrapper
.find(Link)
.filterWhere((n) => n.prop('data-test') === 'current-content')
.filterWhere((n: { prop: (arg0: string) => string }) => n.prop('data-test') === 'current-content')
.exists(),
).toBeTruthy()

Expand All @@ -501,7 +501,7 @@ describe('Picker component', () => {
expect(
wrapper
.find(Link)
.filterWhere((n) => n.prop('data-test') === 'current-content')
.filterWhere((n: { prop: (arg0: string) => string }) => n.prop('data-test') === 'current-content')
.exists(),
).toBeFalsy()
})
Expand All @@ -525,6 +525,7 @@ describe('Picker component', () => {
Path: '/Root/Content/HU/Blog/Posts',
},
}

const repositoryHandle = (loadCollectionValue?: unknown) => {
return {
loadCollection: () => {
Expand All @@ -534,7 +535,7 @@ describe('Picker component', () => {
},
}
},
load: (item) => {
load: (item: { idOrPath: string | number }) => {
return {
d: helperItems[item.idOrPath],
}
Expand All @@ -557,10 +558,37 @@ describe('Picker component', () => {
expect(
wrapper
.find(Link)
.filterWhere((n) => n.prop('data-test') === `path-helper-${helperItems['/Root/Content/HU/Blog/Posts'].Path}`)
.filterWhere(
(n: { prop: (arg0: string) => string }) =>
n.prop('data-test') === `path-helper-${helperItems['/Root/Content/HU/Blog/Posts'].Path}`,
)
.exists(),
).toBeTruthy()

//find helper items length of Link inside data-test path-helpers
//click on a helper item

//test current helper items

await act(async () => {
wrapper
.find(Link)
.filterWhere(
(n: { prop: (arg0: string) => string }) =>
n.prop('data-test') === `path-helper-${helperItems['/Root/Content/HU/Blog/Posts'].Path}`,
)
.simulate('click')
})

wrapper.update()

expect(
wrapper
.find(Link)
.filterWhere(
(n: { prop: (arg0: string) => string }) =>
n.prop('data-test') === `path-helper-${helperItems['/Root/Content/HU/Blog/Posts'].Path}`,
)
.exists(),
).toBeTruthy()
})
})

0 comments on commit 59e0252

Please sign in to comment.