Skip to content

Commit

Permalink
Merge pull request #305 from deltaDAO/feat/fix-tests
Browse files Browse the repository at this point in the history
fix: tests
  • Loading branch information
moritzkirstein authored Mar 17, 2023
2 parents 90ac924 + 3635b71 commit e11b899
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .jest/__fixtures__/searchBarStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
isSearchBarVisible: false,
setSearchBarVisible: jest.fn(),
homeSearchBarFocus: false,
setHomeSearchBarFocus: jest.fn()
}
5 changes: 5 additions & 0 deletions .jest/__mocks__/hooksMocks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import marketMetadata from '../__fixtures__/marketMetadata'
import userPreferences from '../__fixtures__/userPreferences'
import searchBarStatus from '../__fixtures__/searchBarStatus'
import web3 from '../__fixtures__/web3'
import { asset } from '../__fixtures__/datasetWithAccessDetails'

Expand All @@ -18,3 +19,7 @@ jest.mock('../../src/@context/Web3', () => ({
jest.mock('../../../@context/Asset', () => ({
useAsset: () => ({ asset })
}))

jest.mock('../../@context/SearchBarStatus', () => ({
useSearchBarStatus: () => searchBarStatus
}))
11 changes: 9 additions & 2 deletions src/@utils/aquarius/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ const defaultBaseQueryReturn = {
query: {
bool: {
filter: [
{ term: { _index: 'oceanv4' } },
{ terms: { chainId: [1, 3] } },
{ term: { _index: 'oceanv4' } },
{ term: { 'purgatory.state': false } },
{ bool: { must_not: [{ term: { 'nft.state': 5 } }] } }
{
bool: {
must_not: [
{ term: { 'nft.state': 5 } },
{ term: { 'price.type': 'pool' } }
]
}
}
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/@utils/aquarius/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
SortTermOptions
} from '../../@types/aquarius/SearchQuery'
import { transformAssetToAssetSelection } from '../assetConvertor'
import addressConfig from 'address.config'
import addressConfig from '../../../address.config'

export interface UserSales {
id: string
Expand Down
2 changes: 1 addition & 1 deletion src/components/@shared/atoms/Button/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test('returns correct markup when href or to is passed', async () => {
<Button href="https://oceanprotocol.com">Hello Button</Button>
)

let button = screen.getByText('Hello Button')
let button = screen.getByText(`Hello Button ${String.fromCharCode(8599)}`)
expect(button).toHaveAttribute('href', 'https://oceanprotocol.com')
expect(button).toContainHTML('<a')

Expand Down
11 changes: 5 additions & 6 deletions src/components/Header/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,19 @@ export default function SearchBar({
const router = useRouter()
const [value, setValue] = useState(initialValue || '')
const parsed = router.query
const { text, owner } = parsed
const isHome = window.location.pathname === '/'
const searchBarRef = useRef<HTMLInputElement>(null)
const {
isSearchBarVisible,
setSearchBarVisible,
homeSearchBarFocus,
setHomeSearchBarFocus
} = useSearchBarStatus()
const isHome = window.location.pathname === '/'

const searchBarRef = useRef<HTMLInputElement>(null)

useEffect(() => {
if (text || owner) setValue((text || owner) as string)
}, [text, owner])
if (parsed?.text || parsed?.owner)
setValue((parsed?.text || parsed?.owner) as string)
}, [parsed?.text, parsed?.owner])

useEffect(() => {
setSearchBarVisible(false)
Expand Down

1 comment on commit e11b899

@vercel
Copy link

@vercel vercel bot commented on e11b899 Mar 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.