Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
LeahMarieBush committed Apr 18, 2024
1 parent 41591eb commit 3b73402
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions packages/alert-banner/index.test.js
Expand Up @@ -3,9 +3,7 @@
* SPDX-License-Identifier: MPL-2.0
*/

import { fireEvent, render, screen } from '@testing-library/react'
import cookie from 'js-cookie'
import slugify from 'slugify'
import { render, screen } from '@testing-library/react'
import AlertBanner from './'

/**
Expand All @@ -30,23 +28,6 @@ describe('<AlertBanner />', () => {
expect(linkElem.href).toBe(url)
})

it('should allow closing the banner, and set a cookie to remember', () => {
const tag = 'Newish'
const text = 'This is a cool banner'
const linkText = 'Check it out'
const { container } = render(
<AlertBanner tag={tag} text={text} linkText={linkText} />
)
const rootElem = container.firstChild
const closeButton = screen.getByText('Dismiss alert')
expect(rootElem).toHaveClass('isShown')
fireEvent.click(closeButton)
expect(rootElem).not.toHaveClass('isShown')

const dismissalCookieId = `banner_${slugify(text, { lower: true })}`
expect(cookie.get(dismissalCookieId)).toBe('1')
})

describe('with an expiration date set', () => {
beforeAll(() => {
// Lock Date.now() with value of Oct. 20, 2020
Expand Down

0 comments on commit 3b73402

Please sign in to comment.