navs.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import assert from 'assert';
  2. import React from 'react'; // jshint ignore:line
  3. import { TabsNav, CompactNav } from 'misago/components/threads/navs'; // jshint ignore:line
  4. import * as testUtils from 'misago/utils/test-utils';
  5. let props = {
  6. lists: [
  7. {
  8. path: '',
  9. name: gettext("All"),
  10. longName: gettext("All threads")
  11. },
  12. {
  13. path: 'new/',
  14. name: gettext("New"),
  15. longName: gettext("New threads")
  16. }
  17. ],
  18. list: {
  19. path: 'new/',
  20. name: gettext("New"),
  21. longName: gettext("New threads")
  22. }
  23. };
  24. describe("Threads List Navs", function() {
  25. afterEach(function() {
  26. testUtils.unmountComponents();
  27. });
  28. it("renders tab nav", function(done) {
  29. /* jshint ignore:start */
  30. testUtils.render(<TabsNav {...props} />);
  31. /* jshint ignore:end */
  32. testUtils.onElement('#test-mount .page-tabs', function() {
  33. assert.ok(true, "component renders");
  34. props.lists.forEach(function(list, i) {
  35. let element = $($('#test-mount a')[i]);
  36. assert.ok(element.length, "list has its link in menu");
  37. assert.equal(element.find('.hidden-xs').text(), list.name,
  38. "list has its name in menu");
  39. assert.equal(element.find('.hidden-md').text(), list.longName,
  40. "list has its long name in menu");
  41. });
  42. done();
  43. });
  44. });
  45. it("renders compact nav", function(done) {
  46. /* jshint ignore:start */
  47. testUtils.render(<CompactNav {...props} />);
  48. /* jshint ignore:end */
  49. testUtils.onElement('#test-mount .dropdown-menu', function() {
  50. assert.ok(true, "component renders");
  51. props.lists.forEach(function(list, i) {
  52. let element = $($('#test-mount a')[i]);
  53. assert.ok(element.length, "list has its link in menu");
  54. assert.equal(element.find('.hidden-xs').text(), list.name,
  55. "list has its name in menu");
  56. assert.equal(element.find('.hidden-md').text(), list.longName,
  57. "list has its long name in menu");
  58. });
  59. done();
  60. });
  61. });
  62. });