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.

merge-strategy.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @filedescription Merge Strategy Tests
  3. */
  4. /* global it, describe, beforeEach */
  5. "use strict";
  6. //-----------------------------------------------------------------------------
  7. // Requirements
  8. //-----------------------------------------------------------------------------
  9. const assert = require("chai").assert;
  10. const { MergeStrategy } = require("../src/");
  11. //-----------------------------------------------------------------------------
  12. // Class
  13. //-----------------------------------------------------------------------------
  14. describe("MergeStrategy", () => {
  15. describe("overwrite()", () => {
  16. it("should overwrite the first value with the second when the second is defined", () => {
  17. const result = MergeStrategy.overwrite(1, 2);
  18. assert.strictEqual(result, 2);
  19. });
  20. it("should overwrite the first value with the second when the second is undefined", () => {
  21. const result = MergeStrategy.overwrite(1, undefined);
  22. assert.strictEqual(result, undefined);
  23. });
  24. });
  25. describe("replace()", () => {
  26. it("should overwrite the first value with the second when the second is defined", () => {
  27. const result = MergeStrategy.replace(1, 2);
  28. assert.strictEqual(result, 2);
  29. });
  30. it("should return the first value when the second is undefined", () => {
  31. const result = MergeStrategy.replace(1, undefined);
  32. assert.strictEqual(result, 1);
  33. });
  34. });
  35. describe("assign()", () => {
  36. it("should merge properties from two objects when called", () => {
  37. const object1 = { foo: 1, bar: 3 };
  38. const object2 = { foo: 2 };
  39. const result = MergeStrategy.assign(object1, object2);
  40. assert.deepStrictEqual(result, {
  41. foo: 2,
  42. bar: 3
  43. });
  44. });
  45. });
  46. });