Skip to content

Commit

Permalink
Assign colors, and then assign colors to keys (#1799)
Browse files Browse the repository at this point in the history
* Assign colors, and then assign colors to keys

* added unit test to check RGB.prototype[Animation.keys] initialized
  • Loading branch information
fisher-alice authored Dec 3, 2022
1 parent b5259d8 commit 5d5e301
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/led/rgb.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,14 +434,15 @@ class RGB {


}

RGB.colors = ["red", "green", "blue"];

/**
* For multi-property animation, must define
* the keys to use for tween calculation.
*/
RGB.prototype[Animation.keys] = RGB.colors;

RGB.colors = ["red", "green", "blue"];

RGB.ToScaledRGB = (intensity, colors) => {
const scale = intensity / 100;

Expand Down
8 changes: 8 additions & 0 deletions test/rgb.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,14 @@ exports["RGB"] = {
test.done();
},

"Animation.keys"(test) {
test.expect(1);
this.color = this.sandbox.stub(this.rgb, "color");
const keys = this.rgb[Animation.keys];
test.deepEqual(keys, ["red", "green", "blue"]);
test.done();
},

};

exports["10-bit RGB"] = {
Expand Down

0 comments on commit 5d5e301

Please sign in to comment.