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.

updatenotification_spec.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. const path = require("path");
  2. const git_Helper = require("../../../modules/default/updatenotification/git_helper.js");
  3. const gitHelper = new git_Helper.gitHelper();
  4. gitHelper.add("default");
  5. const test1 = {
  6. module: "test1",
  7. folder: "",
  8. res: {
  9. stdout: "## master...origin/master [behind 8]",
  10. stderr: ""
  11. },
  12. gitInfo: {
  13. module: "default",
  14. // commits behind:
  15. behind: 0,
  16. // branch name:
  17. current: "develop",
  18. // current hash:
  19. hash: "",
  20. // remote branch:
  21. tracking: "",
  22. isBehindInStatus: false
  23. }
  24. };
  25. const test2 = {
  26. module: "test2",
  27. folder: "",
  28. res: {
  29. stdout: "## develop...origin/develop",
  30. stderr: ""
  31. }
  32. };
  33. const test3 = {
  34. module: "test3",
  35. folder: "",
  36. res: {
  37. stdout: "",
  38. stderr: "error"
  39. },
  40. gitInfo: {
  41. module: "default",
  42. // commits behind:
  43. behind: 2,
  44. // branch name:
  45. current: "develop",
  46. // current hash:
  47. hash: "",
  48. // remote branch:
  49. tracking: "",
  50. isBehindInStatus: true
  51. }
  52. };
  53. const test4 = {
  54. module: "default",
  55. folder: path.join(__dirname, "../../.."),
  56. res: {
  57. stdout: "",
  58. stderr: " e40ddd4..06389e3 develop -> origin/develop"
  59. },
  60. gitInfo: {
  61. module: "default",
  62. // commits behind:
  63. behind: 0,
  64. // branch name:
  65. current: "develop",
  66. // current hash:
  67. hash: "",
  68. // remote branch:
  69. tracking: "",
  70. isBehindInStatus: false
  71. }
  72. };
  73. describe("Updatenotification", function () {
  74. it("should return valid output for git status", async function () {
  75. const arr = await gitHelper.getStatus();
  76. expect(arr.length).toBe(1);
  77. const gitInfo = arr[0];
  78. expect(gitInfo.current).not.toBe("");
  79. expect(gitInfo.hash).not.toBe("");
  80. }, 15000);
  81. it("should return behind=8 for test1", async function () {
  82. const gitInfo = await gitHelper.getStatusInfo(test1);
  83. expect(gitInfo.behind).toBe(8);
  84. expect(gitInfo.isBehindInStatus).toBe(true);
  85. });
  86. it("should return behind=0 for test2", async function () {
  87. const gitInfo = await gitHelper.getStatusInfo(test2);
  88. expect(gitInfo.behind).toBe(0);
  89. expect(gitInfo.isBehindInStatus).toBe(false);
  90. });
  91. it("should return empty status object for test3", async function () {
  92. const gitInfo = await gitHelper.getStatusInfo(test3);
  93. expect(gitInfo).toBe(undefined);
  94. });
  95. it("should return empty repo object for test2", async function () {
  96. // no gitInfo provided in res, so returns undefined
  97. const gitInfo = await gitHelper.getRepoInfo(test2);
  98. expect(gitInfo).toBe(undefined);
  99. });
  100. it("should return empty repo object for test1", async function () {
  101. // no regex match for refs in empty string, so returns undefined
  102. const gitInfo = await gitHelper.getRepoInfo(test1);
  103. expect(gitInfo).toBe(undefined);
  104. });
  105. it("should return empty repo object for test4", async function () {
  106. // git ref list throws error, so returns undefined
  107. const gitInfo = await gitHelper.getRepoInfo(test4);
  108. expect(gitInfo).toBe(undefined);
  109. });
  110. it("should return behind=2 for test3", async function () {
  111. const gitInfo = await gitHelper.getRepoInfo(test3);
  112. expect(gitInfo.behind).toBe(2);
  113. });
  114. });