Skip to content

Commit

Permalink
Add a test case for failing behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
pksjce committed Nov 14, 2023
1 parent ec0d263 commit c18ae86
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/__tests__/anchored-position.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,16 @@ describe('getAnchoredPosition', () => {

// This test runs for values derived from a real use case https://github.com/github/accessibility-audits/issues/4515 as run on a local storybook.
it('should overflow to bottom if the element is too tall to fit on the screen when zoomed', () => {
const parentRect = makeDOMRect(0, 0, 0, 0)
const parentRect = makeDOMRect(0, 0, 400, 400)
const anchorRect = makeDOMRect(16, 16, 32, 32) // left aligned button
const floatingRect = makeDOMRect(0, 0, 256, 428) // 428 is the max height of the screen
const floatingRect = makeDOMRect(0, 0, 256, 428)
const {float, anchor} = createVirtualDOM(parentRect, anchorRect, floatingRect)
const settings: Partial<PositionSettings> = {side: 'outside-bottom', align: 'start'}
const {top, left, anchorSide, anchorAlign} = getAnchoredPosition(float, anchor, settings)
// Not really sure what to expect here.
expect(anchorSide).toEqual('outside-bottom')
expect(anchorAlign).toEqual('center')
expect(top).toEqual(52)
expect(left).toEqual(-256) // Expecting 32, Receiving -256
expect(anchorSide).toEqual('outside-right')
expect(anchorAlign).toEqual('start')
expect(top).toEqual(-28) // should be 16 which is the top start of the anchor element. Negative value is wrong.
expect(left).toEqual(52)
})
})

0 comments on commit c18ae86

Please sign in to comment.