chat-toggle-button.test.js 821 B

123456789101112131415161718192021222324252627
  1. import { expect } from 'chai'
  2. import React from 'react'
  3. import { render, screen } from '@testing-library/react'
  4. import ChatToggleButton from '../../../../../frontend/js/features/editor-navigation-toolbar/components/chat-toggle-button'
  5. describe('<ChatToggleButton />', function () {
  6. const defaultProps = {
  7. chatIsOpen: false,
  8. unreadMessageCount: 0,
  9. onClick: () => {},
  10. }
  11. it('displays the number of unread messages', function () {
  12. const props = {
  13. ...defaultProps,
  14. unreadMessageCount: 113,
  15. }
  16. render(<ChatToggleButton {...props} />)
  17. screen.getByText('113')
  18. })
  19. it("doesn't display the unread messages badge when the number of unread messages is zero", function () {
  20. render(<ChatToggleButton {...defaultProps} />)
  21. expect(screen.queryByText('0')).to.not.exist
  22. })
  23. })