read-icon.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import assert from 'assert';
  2. import React from 'react'; // jshint ignore:line
  3. import ReadIcon from 'misago/components/categories/read-icon'; // jshint ignore:line
  4. import * as testUtils from 'misago/utils/test-utils';
  5. describe("Categories List Category Read Icon", function() {
  6. afterEach(function() {
  7. testUtils.unmountComponents();
  8. });
  9. it("render read", function() {
  10. /* jshint ignore:start */
  11. let category = {
  12. is_read: true,
  13. is_closed: false
  14. };
  15. testUtils.render(<ReadIcon category={category} />);
  16. /* jshint ignore:end */
  17. assert.equal($('#test-mount .read-status.item-read .material-icon').text(),
  18. 'chat_bubble_outline',
  19. "proper icon is displayed");
  20. assert.equal($('#test-mount .read-status').attr('title'),
  21. "This category has no new posts.",
  22. "proper state description is displayed");
  23. });
  24. it("render unread", function() {
  25. /* jshint ignore:start */
  26. let category = {
  27. is_read: false,
  28. is_closed: false
  29. };
  30. testUtils.render(<ReadIcon category={category} />);
  31. /* jshint ignore:end */
  32. assert.equal($('#test-mount .read-status.item-new .material-icon').text(),
  33. 'chat_bubble',
  34. "proper icon is displayed");
  35. assert.equal($('#test-mount .read-status').attr('title'),
  36. "This category has new posts.",
  37. "proper state description is displayed");
  38. });
  39. it("render read (closed)", function() {
  40. /* jshint ignore:start */
  41. let category = {
  42. is_read: true,
  43. is_closed: true
  44. };
  45. testUtils.render(<ReadIcon category={category} />);
  46. /* jshint ignore:end */
  47. assert.equal($('#test-mount .read-status.item-read .material-icon').text(),
  48. 'lock_outline',
  49. "proper icon is displayed");
  50. assert.equal($('#test-mount .read-status').attr('title'),
  51. "This category has no new posts. (closed)",
  52. "proper state description is displayed");
  53. });
  54. it("render unread (closed)", function() {
  55. /* jshint ignore:start */
  56. let category = {
  57. is_read: false,
  58. is_closed: true
  59. };
  60. testUtils.render(<ReadIcon category={category} />);
  61. /* jshint ignore:end */
  62. assert.equal($('#test-mount .read-status.item-new .material-icon').text(),
  63. 'lock',
  64. "proper icon is displayed");
  65. assert.equal($('#test-mount .read-status').attr('title'),
  66. "This category has new posts. (closed)",
  67. "proper state description is displayed");
  68. });
  69. });