stats.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import assert from 'assert';
  2. import React from 'react'; // jshint ignore:line
  3. import Stats from 'misago/components/categories/stats'; // jshint ignore:line
  4. import * as testUtils from 'misago/utils/test-utils';
  5. describe("Categories List Category Stats", function() {
  6. afterEach(function() {
  7. testUtils.unmountComponents();
  8. });
  9. it("renders with zeros", function() {
  10. /* jshint ignore:start */
  11. let category = {
  12. threads: 0,
  13. posts: 0
  14. };
  15. testUtils.render(<Stats category={category} />);
  16. /* jshint ignore:end */
  17. assert.equal($('#test-mount .category-threads').text(), "0 threads",
  18. "proper threads count is displayed");
  19. assert.equal($('#test-mount .category-posts').text(), "0 posts",
  20. "proper threads count is displayed");
  21. });
  22. it("renders with threads", function() {
  23. /* jshint ignore:start */
  24. let category = {
  25. threads: 123,
  26. posts: 0
  27. };
  28. testUtils.render(<Stats category={category} />);
  29. /* jshint ignore:end */
  30. assert.equal($('#test-mount .category-threads').text(), "123 threads",
  31. "proper threads count is displayed");
  32. assert.equal($('#test-mount .category-posts').text(), "0 posts",
  33. "proper threads count is displayed");
  34. });
  35. it("renders with posts", function() {
  36. /* jshint ignore:start */
  37. let category = {
  38. threads: 0,
  39. posts: 123
  40. };
  41. testUtils.render(<Stats category={category} />);
  42. /* jshint ignore:end */
  43. assert.equal($('#test-mount .category-threads').text(), "0 threads",
  44. "proper threads count is displayed");
  45. assert.equal($('#test-mount .category-posts').text(), "123 posts",
  46. "proper threads count is displayed");
  47. });
  48. it("renders with threads and posts", function() {
  49. /* jshint ignore:start */
  50. let category = {
  51. threads: 1,
  52. posts: 4
  53. };
  54. testUtils.render(<Stats category={category} />);
  55. /* jshint ignore:end */
  56. assert.equal($('#test-mount .category-threads').text(), "1 thread",
  57. "proper threads count is displayed");
  58. assert.equal($('#test-mount .category-posts').text(), "4 posts",
  59. "proper threads count is displayed");
  60. });
  61. });