root.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import assert from 'assert';
  2. import moment from 'moment'; // jshint ignore:line
  3. import React from 'react'; // jshint ignore:line
  4. import UsersList from 'misago/components/users-list/root'; // jshint ignore:line
  5. import * as testUtils from 'misago/utils/test-utils';
  6. /* jshint ignore:start */
  7. let users = [
  8. testUtils.mockUser({
  9. title: "Lorem ipsum",
  10. joined_on: moment(),
  11. status: {
  12. is_online: true,
  13. }
  14. })
  15. ];
  16. /* jshint ignore:end */
  17. describe("Users List", function() {
  18. afterEach(function() {
  19. testUtils.unmountComponents();
  20. });
  21. it("renders loaded", function(done) {
  22. /* jshint ignore:start */
  23. testUtils.render(
  24. <UsersList isLoaded={true} users={users} cols={4} />
  25. );
  26. /* jshint ignore:end */
  27. testUtils.onElement('#test-mount .users-cards-list .col-md-3', function() {
  28. assert.ok(true, "component renders with valid col class");
  29. assert.equal($('#test-mount .user-card').length, 1, "user card renders");
  30. assert.ok(!$('#test-mount .user-status').length, "status is hidden");
  31. done();
  32. });
  33. });
  34. it("renders loaded with different col class", function(done) {
  35. /* jshint ignore:start */
  36. testUtils.render(
  37. <UsersList isLoaded={true} users={users} cols={2} />
  38. );
  39. /* jshint ignore:end */
  40. testUtils.onElement('#test-mount .users-cards-list .col-md-6', function() {
  41. assert.ok(true, "component renders with valid col class");
  42. assert.equal($('#test-mount .user-card').length, 1, "user card renders");
  43. assert.ok(!$('#test-mount .user-status').length, "status is hidden");
  44. done();
  45. });
  46. });
  47. it("renders loaded with users status", function(done) {
  48. /* jshint ignore:start */
  49. testUtils.render(
  50. <UsersList isLoaded={true} users={users} cols={4} showStatus={true} />
  51. );
  52. /* jshint ignore:end */
  53. testUtils.onElement('#test-mount .users-cards-list .col-md-3', function() {
  54. assert.ok(true, "component renders with valid col class");
  55. assert.equal($('#test-mount .user-card').length, 1, "user card renders");
  56. assert.ok($('#test-mount .user-status').length, "status is shown");
  57. done();
  58. });
  59. });
  60. it("renders preview", function(done) {
  61. /* jshint ignore:start */
  62. testUtils.render(
  63. <UsersList isLoaded={false} cols={4} />
  64. );
  65. /* jshint ignore:end */
  66. testUtils.onElement('#test-mount .users-cards-list .col-md-3', function() {
  67. assert.ok(true, "component renders with valid col class");
  68. assert.equal($('#test-mount .user-card').length, 4, "user card renders");
  69. assert.ok(!$('#test-mount .user-status').length, "status is hidden");
  70. done();
  71. });
  72. });
  73. it("renders preview with different col class", function(done) {
  74. /* jshint ignore:start */
  75. testUtils.render(
  76. <UsersList isLoaded={false} cols={2} />
  77. );
  78. /* jshint ignore:end */
  79. testUtils.onElement('#test-mount .users-cards-list .col-md-6', function() {
  80. assert.ok(true, "component renders with valid col class");
  81. assert.equal($('#test-mount .user-card').length, 2, "user card renders");
  82. assert.ok(!$('#test-mount .user-status').length, "status is hidden");
  83. done();
  84. });
  85. });
  86. it("renders preview with users status", function(done) {
  87. /* jshint ignore:start */
  88. testUtils.render(
  89. <UsersList isLoaded={false} cols={4} showStatus={true} />
  90. );
  91. /* jshint ignore:end */
  92. testUtils.onElement('#test-mount .users-cards-list .col-md-3', function() {
  93. assert.ok(true, "component renders with valid col class");
  94. assert.equal($('#test-mount .user-card').length, 4, "user card renders");
  95. assert.ok($('#test-mount .user-status').length, "status is shown");
  96. done();
  97. });
  98. });
  99. });