navs.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import assert from 'assert';
  2. import React from 'react'; // jshint ignore:line
  3. import { SideNav, CompactNav } from 'misago/components/options/navs'; // jshint ignore:line
  4. import * as testUtils from 'misago/utils/test-utils';
  5. let options = {
  6. baseUrl: '/options/',
  7. options: [
  8. {
  9. component: "forum-options",
  10. icon: "settings",
  11. name: "Forum options"
  12. },
  13. {
  14. component: "change-username",
  15. icon: "card_membership",
  16. name: "Change username"
  17. },
  18. {
  19. component: "sign-in-credentials",
  20. icon: "vpn_key",
  21. name: "Change sign-in credentials"
  22. }
  23. ]
  24. };
  25. describe("Options Navs", function() {
  26. afterEach(function() {
  27. testUtils.unmountComponents();
  28. });
  29. it("renders side nav", function(done) {
  30. /* jshint ignore:start */
  31. testUtils.render(<SideNav {...options} />);
  32. /* jshint ignore:end */
  33. testUtils.onElement('#test-mount .nav-side', function() {
  34. assert.ok(true, "component renders");
  35. options.options.forEach(function(option, i) {
  36. let element = $($('#test-mount a')[i]);
  37. assert.ok(element.length, "option has its link in menu");
  38. assert.equal(element.find('.material-icon').text().trim(), option.icon,
  39. "option has its icon in menu");
  40. assert.ok(element.text().indexOf(option.name) !== -1,
  41. "option has its name in menu");
  42. });
  43. done();
  44. });
  45. });
  46. it("renders compact nav", function(done) {
  47. /* jshint ignore:start */
  48. testUtils.render(<CompactNav {...options} />);
  49. /* jshint ignore:end */
  50. testUtils.onElement('#test-mount .dropdown-menu', function() {
  51. assert.ok(true, "component renders");
  52. options.options.forEach(function(option, i) {
  53. let element = $($('#test-mount a')[i]);
  54. assert.ok(element.length, "option has its link in menu");
  55. assert.equal(element.find('.material-icon').text().trim(), option.icon,
  56. "option has its icon in menu");
  57. assert.ok(element.text().indexOf(option.name) !== -1,
  58. "option has its name in menu");
  59. });
  60. done();
  61. });
  62. });
  63. });