@@ -1373,19 +1373,21 @@ describe("LegoWidget — _addColorSegment", () => {
13731373 expect ( legoWidget . colorData [ 0 ] . colorSegments [ 1 ] . duration ) . toBe ( 1000 ) ;
13741374 } ) ;
13751375
1376- it ( "should throw when initializing a new entry due to the this.this typo bug" , ( ) => {
1377- // This test documents the known production bug: this.this.matrixData
1378- // on line 2772-2773 of legobricks.js. When colorData[rowIndex] does not
1379- // exist yet, _addColorSegment tries to read this.this.matrixData which
1380- // causes a TypeError because this.this is undefined.
1376+ it ( "should initialize a new entry correctly when colorData is empty" , ( ) => {
1377+ // This test proves that the previous typo bug (this.this.matrixData)
1378+ // is fixed and _addColorSegment correctly initializes the row.
13811379 legoWidget . colorData = [ ] ;
13821380 legoWidget . matrixData = {
13831381 rows : [ { note : "C4" , label : "Do (4)" } ]
13841382 } ;
13851383
1386- expect ( ( ) => {
1387- legoWidget . _addColorSegment ( 0 , { name : "red" } , 1500 ) ;
1388- } ) . toThrow ( TypeError ) ;
1384+ legoWidget . _addColorSegment ( 0 , { name : "red" } , 1500 ) ;
1385+
1386+ expect ( legoWidget . colorData [ 0 ] . note ) . toBe ( "C4" ) ;
1387+ expect ( legoWidget . colorData [ 0 ] . label ) . toBe ( "Do (4)" ) ;
1388+ expect ( legoWidget . colorData [ 0 ] . colorSegments ) . toHaveLength ( 1 ) ;
1389+ expect ( legoWidget . colorData [ 0 ] . colorSegments [ 0 ] . color ) . toBe ( "red" ) ;
1390+ expect ( legoWidget . colorData [ 0 ] . colorSegments [ 0 ] . duration ) . toBe ( 1500 ) ;
13891391 } ) ;
13901392
13911393 it ( "should not throw when appending to a pre-populated colorData entry" , ( ) => {
0 commit comments