Skip to content

Commit 3addb29

Browse files
authored
Updating SOCComponent.test.js (#251)
1 parent 2ce7972 commit 3addb29

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

src/tests/SOCComponent.test.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ describe('SOCComponent', () => {
6161
test('renders SOCComponent with correct child components', () => {
6262
render(<SOCComponent device="test-device" setOpenedTable={mockSetOpenedTable} peripherals={mockPeripherals} />);
6363

64-
const acpuComponents = screen.getAllByText('Mocked ABCPUComponent');
65-
expect(acpuComponents.length).toBe(2);
66-
64+
expect(screen.getAllByText('Mocked ABCPUComponent').length).toBe(2);
6765
expect(screen.getByText('Mocked TitleComponent')).toBeInTheDocument();
6866
expect(screen.getByText('Mocked DMAComponent')).toBeInTheDocument();
6967
expect(screen.getByText('Mocked ConnectivityComponent')).toBeInTheDocument();
@@ -75,7 +73,6 @@ describe('SOCComponent', () => {
7573

7674
const acpuElement = screen.getAllByText('Mocked ABCPUComponent')[0];
7775
fireEvent.click(acpuElement);
78-
7976
expect(mockSetOpenedTable).toHaveBeenCalledWith(Table.ACPU);
8077
});
8178

@@ -84,7 +81,6 @@ describe('SOCComponent', () => {
8481

8582
const bcpuElement = screen.getAllByText('Mocked ABCPUComponent')[1];
8683
fireEvent.click(bcpuElement);
87-
8884
expect(mockSetOpenedTable).toHaveBeenCalledWith(Table.BCPU);
8985
});
9086

@@ -93,7 +89,6 @@ describe('SOCComponent', () => {
9389

9490
const dmaElement = screen.getByText('Mocked DMAComponent');
9591
fireEvent.click(dmaElement);
96-
9792
expect(mockSetOpenedTable).toHaveBeenCalledWith(Table.DMA);
9893
});
9994

@@ -102,7 +97,6 @@ describe('SOCComponent', () => {
10297

10398
const connectivityElement = screen.getByText('Mocked ConnectivityComponent');
10499
fireEvent.click(connectivityElement);
105-
106100
expect(mockSetOpenedTable).toHaveBeenCalledWith(Table.Connectivity);
107101
});
108102

@@ -111,7 +105,36 @@ describe('SOCComponent', () => {
111105

112106
const peripheralsElement = screen.getByText('Mocked PeripheralsComponent');
113107
fireEvent.click(peripheralsElement);
114-
115108
expect(mockSetOpenedTable).toHaveBeenCalledWith(Table.Peripherals);
116109
});
110+
111+
test('displays correct dynamic power values in TitleComponent', () => {
112+
render(<SOCComponent device="test-device" setOpenedTable={mockSetOpenedTable} peripherals={mockPeripherals} />);
113+
114+
const dynamicPower = useSocTotalPower().totalConsumption.processing_complex.dynamic.power;
115+
const dynamicPercentage = useSocTotalPower().totalConsumption.processing_complex.dynamic.percentage;
116+
117+
expect(dynamicPower).toBe(100);
118+
expect(dynamicPercentage).toBe(50);
119+
});
120+
121+
test('displays correct static power values in TitleComponent', () => {
122+
render(<SOCComponent device="test-device" setOpenedTable={mockSetOpenedTable} peripherals={mockPeripherals} />);
123+
124+
const staticPower = useSocTotalPower().totalConsumption.processing_complex.static.power;
125+
const staticPercentage = useSocTotalPower().totalConsumption.processing_complex.static.percentage;
126+
127+
expect(staticPower).toBe(30);
128+
expect(staticPercentage).toBe(10);
129+
});
130+
131+
test('displays correct total power values in TitleComponent', () => {
132+
render(<SOCComponent device="test-device" setOpenedTable={mockSetOpenedTable} peripherals={mockPeripherals} />);
133+
134+
const totalPower = useSocTotalPower().totalConsumption.processing_complex.total_power;
135+
const totalPercentage = useSocTotalPower().totalConsumption.processing_complex.total_percentage;
136+
137+
expect(totalPower).toBe(130);
138+
expect(totalPercentage).toBe(60);
139+
});
117140
});

0 commit comments

Comments
 (0)