errors-list.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import assert from 'assert';
  2. import React from 'react'; // jshint ignore:line
  3. import ErrorsList from 'misago/components/threads/moderation/errors-list'; // jshint ignore:line
  4. import * as testUtils from 'misago/utils/test-utils';
  5. describe("Threads List Moderation Errors List", function() {
  6. afterEach(function() {
  7. testUtils.unmountComponents();
  8. });
  9. it("renders", function() {
  10. const errors = [
  11. {
  12. thread: {
  13. id: 123,
  14. title: "Lorem ipsum dolor met"
  15. },
  16. errors: [
  17. "Requested thread could not be found."
  18. ]
  19. },
  20. {
  21. thread: {
  22. id: 124,
  23. title: "Test thread"
  24. },
  25. errors: [
  26. "You don't have permission to pin this thread.",
  27. "You don't have permission to close this thread."
  28. ]
  29. }
  30. ];
  31. /* jshint ignore:start */
  32. testUtils.render(<ErrorsList errors={errors} />);
  33. /* jshint ignore:end */
  34. const element = $('#test-mount .modal-dialog');
  35. assert.ok(element.length, "component renders");
  36. assert.equal(element.find('.list-item-errors').length, 2,
  37. "two threads errors lists are displayed");
  38. const errorsList = element.find('.list-item-errors li');
  39. assert.equal(errorsList.length, 3, "three errors are displayed");
  40. assert.equal(errorsList.eq(0).text(), errors[0].errors[0],
  41. "valid error is displayed");
  42. assert.equal(errorsList.eq(1).text(), errors[1].errors[0],
  43. "valid error is displayed");
  44. assert.equal(errorsList.eq(2).text(), errors[1].errors[1],
  45. "valid error is displayed");
  46. });
  47. });