import React from 'react';
import '@testing-library/jest-dom/extend-expect';
import { render } from '@testing-library/react';
import { Notification, Notifications } from './index';
import { Link } from '../../Link';
var MOCK_NOTIFICATION = /*#__PURE__*/React.createElement(Notification, {
  "data-arbitrary": "arbitrary-notification",
  link: /*#__PURE__*/React.createElement(Link, {
    href: "notifications/1"
  }),
  name: "Thomas Stephens",
  action: "added a new comment to your",
  on: "review",
  when: new Date('2019-11-05T10:57:00.000Z'),
  description: "A long description that will be shortened"
});
describe('Notifications', function () {
  describe('default props', function () {
    var wrapper;
    beforeEach(function () {
      wrapper = render( /*#__PURE__*/React.createElement(Notifications, {
        "data-arbitrary": "arbitrary-notifications",
        link: /*#__PURE__*/React.createElement(Link, {
          href: "notifications"
        })
      }, MOCK_NOTIFICATION, MOCK_NOTIFICATION));
    });
    it('should spread arbitrary props on the notifications', function () {
      expect(wrapper.getByTestId('notifications-sheet')).toHaveAttribute('data-arbitrary', 'arbitrary-notifications');
    });
    it('should spread arbitrary props on the notifications item', function () {
      expect(wrapper.getAllByTestId('notification')[0]).toHaveAttribute('data-arbitrary', 'arbitrary-notification');
    });
    it('should render the items', function () {
      var items = wrapper.getAllByTestId('notification');
      expect(items).toHaveLength(2);
    });
    it('should set the `aria-describedby` attribute of each notification row to the ID of the description', function () {
      var contentIds = wrapper.getAllByTestId('notification-content').map(function (content) {
        return content.getAttribute('id');
      });
      var items = wrapper.getAllByTestId('notification-row');
      items.forEach(function (item, i) {
        expect(item).toHaveAttribute('aria-describedby', contentIds[i]);
      });
    });
    it('should render a link to view all', function () {
      var viewAll = wrapper.getByText('View all notifications');
      expect(viewAll).toHaveAttribute('href', 'notifications');
    });
  });
});