From 7dc89ea5052d573b552b67bb7d40b1e3993cc454 Mon Sep 17 00:00:00 2001 From: Natan Muntean Date: Thu, 25 Jan 2024 13:21:48 +0200 Subject: [PATCH] fixed wafer map component test warnings --- .../tests/prerendering.coloring.spec.ts | 112 ++++++++++-------- .../tests/prerendering.labeling.spec.ts | 73 +++++++----- .../tests/prerendering.positioning.spec.ts | 72 +++++------ 3 files changed, 148 insertions(+), 109 deletions(-) diff --git a/packages/nimble-components/src/wafer-map/tests/prerendering.coloring.spec.ts b/packages/nimble-components/src/wafer-map/tests/prerendering.coloring.spec.ts index 770a95977f..1fca074a77 100644 --- a/packages/nimble-components/src/wafer-map/tests/prerendering.coloring.spec.ts +++ b/packages/nimble-components/src/wafer-map/tests/prerendering.coloring.spec.ts @@ -50,9 +50,13 @@ describe('Wafermap Prerendering module', () => { }); it('should have black fill style for all dies', () => { - for (const dieRenderInfo of prerenderingModule.diesRenderInfo) { - expect(dieRenderInfo.fillStyle).toEqual(emptyDieColor); - } + const expectedValues = Array(18).fill(emptyDieColor); + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.fillStyle + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); @@ -91,9 +95,13 @@ describe('Wafermap Prerendering module', () => { }); it('should have the same fill style for all dies', () => { - for (const dieRenderInfo of prerenderingModule.diesRenderInfo) { - expect(dieRenderInfo.fillStyle).toEqual('rgba(255,0,0,1)'); - } + const expectedValues = Array(18).fill('rgba(255,0,0,1)'); + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.fillStyle + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); @@ -134,17 +142,14 @@ describe('Wafermap Prerendering module', () => { it('should have the fill style equally distributed to dies', () => { const waferMapDies = getWaferMapDies(); const expectedValues = waferMapDies.map(waferMapDie => { - return { - fillStyle: `rgba(${ - (+waferMapDie.value - 1) * 15 - },0,0,1)` - }; + return `rgba(${(+waferMapDie.value - 1) * 15},0,0,1)`; }); - for (let i = 0; i < waferMapDies.length; i += 1) { - expect( - prerenderingModule.diesRenderInfo[i]!.fillStyle - ).toEqual(expectedValues[i]!.fillStyle); - } + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.fillStyle + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); }); @@ -184,9 +189,13 @@ describe('Wafermap Prerendering module', () => { }); it('should have the same fill style for all dies', () => { - for (const dieRenderInfo of prerenderingModule.diesRenderInfo) { - expect(dieRenderInfo.fillStyle).toEqual('rgba(255,0,0,1)'); - } + const expectedValues = Array(18).fill('rgba(255,0,0,1)'); + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.fillStyle + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); @@ -227,18 +236,16 @@ describe('Wafermap Prerendering module', () => { it('should have alternating fill style for the dies', () => { const waferMapDies = getWaferMapDies(); const expectedValues = waferMapDies.map(waferMapDie => { - const fillStyle = +waferMapDie.value % 2 === 1 + return +waferMapDie.value % 2 === 1 ? 'rgba(0,0,0,1)' : 'rgba(255,0,0,1)'; - return { - fillStyle - }; }); - for (let i = 0; i < waferMapDies.length; i += 1) { - expect( - prerenderingModule.diesRenderInfo[i]!.fillStyle - ).toEqual(expectedValues[i]!.fillStyle); - } + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.fillStyle + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); }); @@ -284,9 +291,13 @@ describe('Wafermap Prerendering module', () => { }); it('should have NaN color fill style', () => { - for (const dieRenderInfo of prerenderingModule.diesRenderInfo) { - expect(dieRenderInfo.fillStyle).toEqual(nanDieColor); - } + const expectedValues = Array(18).fill(nanDieColor); + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.fillStyle + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); @@ -331,9 +342,13 @@ describe('Wafermap Prerendering module', () => { }); it('should have empty color fill style', () => { - for (const dieRenderInfo of prerenderingModule.diesRenderInfo) { - expect(dieRenderInfo.fillStyle).toEqual(emptyDieColor); - } + const expectedValues = Array(18).fill(emptyDieColor); + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.fillStyle + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); @@ -372,20 +387,17 @@ describe('Wafermap Prerendering module', () => { const waferMapDies = getWaferMapDies(); const expectedValues = waferMapDies.map(waferMapDie => { if (!waferMapDie.tags) { - return { - fillStyle: 'rgba(255,0,0,0.3)' - }; + return 'rgba(255,0,0,0.3)'; } const opacity = waferMapDie.tags[0] === highlightedTag ? 1 : 0.3; - return { - fillStyle: `rgba(255,0,0,${opacity})` - }; + return `rgba(255,0,0,${opacity})`; }); - for (let i = 0; i < waferMapDies.length; i += 1) { - expect(prerenderingModule.diesRenderInfo[i]!.fillStyle).toEqual( - expectedValues[i]!.fillStyle - ); - } + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.fillStyle + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); @@ -421,9 +433,13 @@ describe('Wafermap Prerendering module', () => { }); it('should have all dies with full opacity', () => { - for (const dieRenderInfo of prerenderingModule.diesRenderInfo) { - expect(dieRenderInfo.fillStyle).toEqual('rgba(255,0,0,1)'); - } + const expectedValues = Array(18).fill('rgba(255,0,0,1)'); + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.fillStyle + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); }); diff --git a/packages/nimble-components/src/wafer-map/tests/prerendering.labeling.spec.ts b/packages/nimble-components/src/wafer-map/tests/prerendering.labeling.spec.ts index 02b24608a7..60c98db5b8 100644 --- a/packages/nimble-components/src/wafer-map/tests/prerendering.labeling.spec.ts +++ b/packages/nimble-components/src/wafer-map/tests/prerendering.labeling.spec.ts @@ -129,8 +129,12 @@ describe('Wafermap Prerendering module', () => { }); it('should have label suffix for each die', () => { - for (const dieRenderInfo of prerenderingModule.diesRenderInfo) { - expect(dieRenderInfo.text).toContain(dieLabelsSuffix); + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.text + ); + expect(actualValues).not.toHaveSize(0); + for (const value of actualValues) { + expect(value).toContain(dieLabelsSuffix); } }); }); @@ -167,9 +171,13 @@ describe('Wafermap Prerendering module', () => { }); it('should not have full label suffix for each die and end in ellipsis', () => { - for (const dieRenderInfo of prerenderingModule.diesRenderInfo) { - expect(dieRenderInfo.text).not.toContain(dieLabelsSuffix); - expect(dieRenderInfo.text).toContain('…'); + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.text + ); + expect(actualValues).not.toHaveSize(0); + for (const value of actualValues) { + expect(value).not.toContain(dieLabelsSuffix); + expect(value).toContain('…'); } }); }); @@ -207,11 +215,15 @@ describe('Wafermap Prerendering module', () => { it('should have labels equal with values for each die', () => { const waferMapDies = getWaferMapDies(); - for (let i = 0; i < waferMapDies.length; i += 1) { - expect(prerenderingModule.diesRenderInfo[i]!.text).toEqual( - waferMapDies[i]!.value - ); - } + const expectedValues = waferMapDies.map( + waferMapDie => waferMapDie.value + ); + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.text + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); @@ -248,11 +260,15 @@ describe('Wafermap Prerendering module', () => { it('should have labels equal with values for each die', () => { const waferMapNaNDies = getWaferMapDiesAsNaN(); - for (let i = 0; i < waferMapNaNDies.length; i += 1) { - expect(prerenderingModule.diesRenderInfo[i]!.text).toEqual( - waferMapNaNDies[i]!.value - ); - } + const expectedValues = waferMapNaNDies.map( + waferMapDie => waferMapDie.value + ); + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.text + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); @@ -292,16 +308,15 @@ describe('Wafermap Prerendering module', () => { + 'but limited by the maximum number of characters and a ellipsis', () => { const waferMapFloatDies = getWaferMapDiesAsFloats(); - const expectedValues = waferMapFloatDies.map(x => { - return { - text: `${x.value.substring(0, maxCharacters)}…` - }; + const expectedValues = waferMapFloatDies.map(waferMapDie => { + return `${waferMapDie.value.substring(0, maxCharacters)}…`; }); - for (let i = 0; i < waferMapFloatDies.length; i += 1) { - expect(prerenderingModule.diesRenderInfo[i]!.text).toEqual( - expectedValues[i]!.text - ); - } + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.text + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); } ); }); @@ -338,9 +353,13 @@ describe('Wafermap Prerendering module', () => { }); it('should have empty label for each die', () => { - for (const dieRenderInfo of prerenderingModule.diesRenderInfo) { - expect(dieRenderInfo.text).toEqual(''); - } + const expectedValues = Array(18).fill(''); + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.text + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); }); diff --git a/packages/nimble-components/src/wafer-map/tests/prerendering.positioning.spec.ts b/packages/nimble-components/src/wafer-map/tests/prerendering.positioning.spec.ts index 28fea0fe3f..a54606c526 100644 --- a/packages/nimble-components/src/wafer-map/tests/prerendering.positioning.spec.ts +++ b/packages/nimble-components/src/wafer-map/tests/prerendering.positioning.spec.ts @@ -47,20 +47,26 @@ describe('Wafermap Prerendering module', () => { it('should have die positions offset from margins', () => { const waferMapDies = getWaferMapDies(); - const expectedValues = waferMapDies.map(die => { - return { - x: die.x + margin.right, - y: die.y + margin.top - }; - }); - for (let i = 0; i < waferMapDies.length; i += 1) { - expect(prerenderingModule.diesRenderInfo[i]!.x).toEqual( - expectedValues[i]!.x - ); - expect(prerenderingModule.diesRenderInfo[i]!.y).toEqual( - expectedValues[i]!.y - ); - } + + let expectedValues = waferMapDies.map( + waferMapDie => waferMapDie.x + margin.right + ); + let actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.x + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); + + expectedValues = waferMapDies.map( + waferMapDie => waferMapDie.y + margin.top + ); + actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.y + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); @@ -101,16 +107,15 @@ describe('Wafermap Prerendering module', () => { it('should have die horizontal position scaled', () => { const waferMapDies = getWaferMapDies(); - const expectedValues = waferMapDies.map(x => { - return { - x: x.x * 10 - }; - }); - for (let i = 0; i < waferMapDies.length; i += 1) { - expect(prerenderingModule.diesRenderInfo[i]!.x).toEqual( - expectedValues[i]!.x - ); - } + const expectedValues = waferMapDies.map( + waferMapDie => waferMapDie.x * 10 + ); + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.x + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); @@ -151,16 +156,15 @@ describe('Wafermap Prerendering module', () => { it('should have die horizontal position scaled', () => { const waferMapDies = getWaferMapDies(); - const expectedValues = waferMapDies.map(waferMapDie => { - return { - y: waferMapDie.y * 10 - }; - }); - for (let i = 0; i < waferMapDies.length; i += 1) { - expect(prerenderingModule.diesRenderInfo[i]!.y).toEqual( - expectedValues[i]!.y - ); - } + const expectedValues = waferMapDies.map( + waferMapDie => waferMapDie.y * 10 + ); + const actualValues = prerenderingModule.diesRenderInfo.map( + dieRenderInfo => dieRenderInfo.y + ); + expect(actualValues).toEqual( + jasmine.arrayWithExactContents(expectedValues) + ); }); }); });