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.

compliments_spec.js 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. const helpers = require("../global-setup");
  2. /**
  3. * move similar tests in function doTest
  4. *
  5. * @param {Array} complimentsArray The array of compliments.
  6. */
  7. function doTest(complimentsArray) {
  8. let elem = document.querySelector(".compliments");
  9. expect(elem).not.toBe(null);
  10. elem = document.querySelector(".module-content");
  11. expect(elem).not.toBe(null);
  12. expect(complimentsArray).toContain(elem.textContent);
  13. }
  14. describe("Compliments module", function () {
  15. afterAll(function () {
  16. helpers.stopApplication();
  17. });
  18. describe("parts of days", function () {
  19. beforeAll(function (done) {
  20. helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js");
  21. helpers.getDocument(done, 1000);
  22. });
  23. it("if Morning compliments for that part of day", function () {
  24. const hour = new Date().getHours();
  25. if (hour >= 3 && hour < 12) {
  26. // if morning check
  27. doTest(["Hi", "Good Morning", "Morning test"]);
  28. }
  29. });
  30. it("if Afternoon show Compliments for that part of day", function () {
  31. const hour = new Date().getHours();
  32. if (hour >= 12 && hour < 17) {
  33. // if afternoon check
  34. doTest(["Hello", "Good Afternoon", "Afternoon test"]);
  35. }
  36. });
  37. it("if Evening show Compliments for that part of day", function () {
  38. const hour = new Date().getHours();
  39. if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) {
  40. // if evening check
  41. doTest(["Hello There", "Good Evening", "Evening test"]);
  42. }
  43. });
  44. });
  45. describe("Feature anytime in compliments module", function () {
  46. describe("Set anytime and empty compliments for morning, evening and afternoon ", function () {
  47. beforeAll(function (done) {
  48. helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js");
  49. helpers.getDocument(done, 1000);
  50. });
  51. it("Show anytime because if configure empty parts of day compliments and set anytime compliments", function () {
  52. doTest(["Anytime here"]);
  53. });
  54. });
  55. describe("Only anytime present in configuration compliments", function () {
  56. beforeAll(function (done) {
  57. helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js");
  58. helpers.getDocument(done, 1000);
  59. });
  60. it("Show anytime compliments", function () {
  61. doTest(["Anytime here"]);
  62. });
  63. });
  64. });
  65. describe("Feature date in compliments module", function () {
  66. describe("Set date and empty compliments for anytime, morning, evening and afternoon", function () {
  67. beforeAll(function (done) {
  68. helpers.startApplication("tests/configs/modules/compliments/compliments_date.js");
  69. helpers.getDocument(done, 1000);
  70. });
  71. it("Show happy new year compliment on new years day", function () {
  72. doTest(["Happy new year!"]);
  73. });
  74. });
  75. });
  76. });