Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
Test fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pelusanchez committed Nov 23, 2023
1 parent fd7b80f commit 2e64b8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions __tests__/components/GenerateBlocks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Generate layout from JSON', () => {
expect(h1?.id).toBe(`abstract-1`)
expect(h1?.innerHTML).toBe(`Here's a Heading`)

const anchor = element.container.querySelector('a')
const anchor = element.container.querySelector('a:not(.anchor)')
expect(anchor?.innerHTML).toBe(`link`)
expect(anchor).toHaveAttribute('href', 'https://google.com')

Expand Down Expand Up @@ -69,7 +69,7 @@ describe('Generate layout from JSON', () => {

screen.getByText('title text section')
screen.getByText('description text example')
const link = document.querySelector('a')
const link = document.querySelector('a:not(.anchor)') as HTMLAnchorElement
expect(link?.href).toBe('https://support.ecmwf.int/')
expect(link?.target).toBe('_blank')
})
Expand Down Expand Up @@ -127,7 +127,9 @@ describe('Generate layout from JSON', () => {
]}
/>,
)
expect(element.container).toBeEmptyDOMElement()

// Check that we only have an anchor
expect(element.container.childElementCount).toBe(1)
})
})
})
Expand Down
4 changes: 3 additions & 1 deletion src/components/GenerateBlocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ const GenerateBlocks = ({
<>
{blocks &&
blocks.map((block, i) => {
if (!generateBlockByType[block.type]) return null
if (!generateBlockByType[block.type]) {
return null
}
return (
<React.Fragment key={`${i}_${block.id}`}>
<Anchor className="anchor" id={block.id} />
Expand Down

0 comments on commit 2e64b8e

Please sign in to comment.