@@ -1079,19 +1079,21 @@ describe("LegoWidget — _addColorSegment", () => {
10791079 expect ( legoWidget . colorData [ 0 ] . colorSegments [ 1 ] . duration ) . toBe ( 1000 ) ;
10801080 } ) ;
10811081
1082- it ( "should throw when initializing a new entry due to the this.this typo bug" , ( ) => {
1083- // This test documents the known production bug: this.this.matrixData
1084- // on line 2772-2773 of legobricks.js. When colorData[rowIndex] does not
1085- // exist yet, _addColorSegment tries to read this.this.matrixData which
1086- // causes a TypeError because this.this is undefined.
1082+ it ( "should initialize a new entry correctly when colorData is empty" , ( ) => {
1083+ // This test proves that the previous typo bug (this.this.matrixData)
1084+ // is fixed and _addColorSegment correctly initializes the row.
10871085 legoWidget . colorData = [ ] ;
10881086 legoWidget . matrixData = {
10891087 rows : [ { note : "C4" , label : "Do (4)" } ]
10901088 } ;
10911089
1092- expect ( ( ) => {
1093- legoWidget . _addColorSegment ( 0 , { name : "red" } , 1500 ) ;
1094- } ) . toThrow ( TypeError ) ;
1090+ legoWidget . _addColorSegment ( 0 , { name : "red" } , 1500 ) ;
1091+
1092+ expect ( legoWidget . colorData [ 0 ] . note ) . toBe ( "C4" ) ;
1093+ expect ( legoWidget . colorData [ 0 ] . label ) . toBe ( "Do (4)" ) ;
1094+ expect ( legoWidget . colorData [ 0 ] . colorSegments ) . toHaveLength ( 1 ) ;
1095+ expect ( legoWidget . colorData [ 0 ] . colorSegments [ 0 ] . color ) . toBe ( "red" ) ;
1096+ expect ( legoWidget . colorData [ 0 ] . colorSegments [ 0 ] . duration ) . toBe ( 1500 ) ;
10951097 } ) ;
10961098
10971099 it ( "should not throw when appending to a pre-populated colorData entry" , ( ) => {
0 commit comments