Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

clock_spec.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. const helpers = require("../global-setup");
  2. const moment = require("moment");
  3. describe("Clock module", function () {
  4. afterAll(function () {
  5. helpers.stopApplication();
  6. });
  7. const testMatch = function (element, regex) {
  8. const elem = document.querySelector(element);
  9. expect(elem).not.toBe(null);
  10. expect(elem.textContent).toMatch(regex);
  11. };
  12. describe("with default 24hr clock config", function () {
  13. beforeAll(function (done) {
  14. helpers.startApplication("tests/configs/modules/clock/clock_24hr.js");
  15. helpers.getDocument(done, 1000);
  16. });
  17. it("should show the date in the correct format", function () {
  18. const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
  19. testMatch(".clock .date", dateRegex);
  20. });
  21. it("should show the time in 24hr format", function () {
  22. const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
  23. testMatch(".clock .time", timeRegex);
  24. });
  25. });
  26. describe("with default 12hr clock config", function () {
  27. beforeAll(function (done) {
  28. helpers.startApplication("tests/configs/modules/clock/clock_12hr.js");
  29. helpers.getDocument(done, 1000);
  30. });
  31. it("should show the date in the correct format", function () {
  32. const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
  33. testMatch(".clock .date", dateRegex);
  34. });
  35. it("should show the time in 12hr format", function () {
  36. const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
  37. testMatch(".clock .time", timeRegex);
  38. });
  39. });
  40. describe("with showPeriodUpper config enabled", function () {
  41. beforeAll(function (done) {
  42. helpers.startApplication("tests/configs/modules/clock/clock_showPeriodUpper.js");
  43. helpers.getDocument(done, 1000);
  44. });
  45. it("should show 12hr time with upper case AM/PM", function () {
  46. const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
  47. testMatch(".clock .time", timeRegex);
  48. });
  49. });
  50. describe("with displaySeconds config disabled", function () {
  51. beforeAll(function (done) {
  52. helpers.startApplication("tests/configs/modules/clock/clock_displaySeconds_false.js");
  53. helpers.getDocument(done, 1000);
  54. });
  55. it("should show 12hr time without seconds am/pm", function () {
  56. const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
  57. testMatch(".clock .time", timeRegex);
  58. });
  59. });
  60. describe("with showTime config disabled", function () {
  61. beforeAll(function (done) {
  62. helpers.startApplication("tests/configs/modules/clock/clock_showTime.js");
  63. helpers.getDocument(done, 1000);
  64. });
  65. it("should show not show the time when digital clock is shown", function () {
  66. const elem = document.querySelector(".clock .digital .time");
  67. expect(elem).toBe(null);
  68. });
  69. });
  70. describe("with showWeek config enabled", function () {
  71. beforeAll(function (done) {
  72. helpers.startApplication("tests/configs/modules/clock/clock_showWeek.js");
  73. helpers.getDocument(done, 1000);
  74. });
  75. it("should show the week in the correct format", function () {
  76. const weekRegex = /^Week [0-9]{1,2}$/;
  77. testMatch(".clock .week", weekRegex);
  78. });
  79. it("should show the week with the correct number of week of year", function () {
  80. const currentWeekNumber = moment().week();
  81. const weekToShow = "Week " + currentWeekNumber;
  82. const elem = document.querySelector(".clock .week");
  83. expect(elem).not.toBe(null);
  84. expect(elem.textContent).toBe(weekToShow);
  85. });
  86. });
  87. describe("with analog clock face enabled", function () {
  88. beforeAll(function (done) {
  89. helpers.startApplication("tests/configs/modules/clock/clock_analog.js");
  90. helpers.getDocument(done, 1000);
  91. });
  92. it("should show the analog clock face", () => {
  93. const elem = document.querySelector(".clockCircle");
  94. expect(elem).not.toBe(null);
  95. });
  96. });
  97. });