li.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import assert from 'assert';
  2. import React from 'react'; // jshint ignore:line
  3. import Li from 'misago/components/li'; // jshint ignore:line
  4. import * as testUtils from 'misago/utils/test-utils';
  5. describe("Li", function() {
  6. afterEach(function() {
  7. testUtils.unmountComponents();
  8. });
  9. it('renders', function() {
  10. /* jshint ignore:start */
  11. testUtils.render(<Li />);
  12. /* jshint ignore:end */
  13. let element = $('#test-mount li');
  14. assert.ok(element.length, "component renders");
  15. });
  16. it('renders with class name', function() {
  17. /* jshint ignore:start */
  18. testUtils.render(<Li className="test-class" />);
  19. /* jshint ignore:end */
  20. let element = $('#test-mount li');
  21. assert.ok(element.hasClass('test-class'), "component renders with class");
  22. assert.ok(!element.hasClass('active'), "component renders with class");
  23. });
  24. it('renders with active class name', function() {
  25. window.history.replaceState({}, '', '/test-server/something/');
  26. /* jshint ignore:start */
  27. testUtils.render(<Li className="test-class"
  28. path="/test-server/something/" />);
  29. /* jshint ignore:end */
  30. let element = $('#test-mount li');
  31. assert.ok(element.hasClass('test-class'), "component renders with class");
  32. assert.ok(element.hasClass('active'), "component has active class");
  33. window.history.replaceState({}, '', '/test-server/something/else-deep/');
  34. /* jshint ignore:start */
  35. testUtils.render(<Li className="test-class"
  36. path="/test-server/something/" />);
  37. /* jshint ignore:end */
  38. element = $('#test-mount li');
  39. assert.ok(element.hasClass('test-class'), "component renders with class");
  40. assert.ok(element.hasClass('active'), "component has active class");
  41. window.history.replaceState({}, '', '/test-server/');
  42. /* jshint ignore:start */
  43. testUtils.render(<Li className="test-class"
  44. path="/test-server/something/" />);
  45. /* jshint ignore:end */
  46. element = $('#test-mount li');
  47. assert.ok(element.hasClass('test-class'), "component renders with class");
  48. assert.ok(!element.hasClass('active'), "component has no active class");
  49. });
  50. it('renders with custom active class', function() {
  51. window.history.replaceState({}, '', '/test-server/something/');
  52. /* jshint ignore:start */
  53. testUtils.render(<Li className="test-class"
  54. path="/test-server/something/"
  55. activeClassName="yay" />);
  56. /* jshint ignore:end */
  57. let element = $('#test-mount li');
  58. assert.ok(element.hasClass('test-class'), "component renders with class");
  59. assert.ok(!element.hasClass('active'), "component has no def active class");
  60. assert.ok(element.hasClass('yay'), "component has custom active class");
  61. window.history.replaceState({}, '', '/test-server/something/else-deep/');
  62. /* jshint ignore:start */
  63. testUtils.render(<Li className="test-class"
  64. path="/test-server/something/"
  65. activeClassName="yay" />);
  66. /* jshint ignore:end */
  67. element = $('#test-mount li');
  68. assert.ok(element.hasClass('test-class'), "component renders with class");
  69. assert.ok(!element.hasClass('active'), "component has no def active class");
  70. assert.ok(element.hasClass('yay'), "component has active class");
  71. window.history.replaceState({}, '', '/test-server/');
  72. /* jshint ignore:start */
  73. testUtils.render(<Li className="test-class"
  74. path="/test-server/something/"
  75. activeClassName="yay" />);
  76. /* jshint ignore:end */
  77. element = $('#test-mount li');
  78. assert.ok(element.hasClass('test-class'), "component renders with class");
  79. assert.ok(!element.hasClass('active'), "component has no def active class");
  80. assert.ok(!element.hasClass('yay'), "component has no active class");
  81. });
  82. });