-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAS-128457 / 24.10 / Elements for new enclosure (#10080)
- Loading branch information
Showing
95 changed files
with
354 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/app/pages/system/enclosure/components/views/elements-view/elements.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { HarnessLoader } from '@angular/cdk/testing'; | ||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; | ||
import { | ||
createRoutingFactory, | ||
mockProvider, | ||
SpectatorRouting, | ||
} from '@ngneat/spectator/jest'; | ||
import { MockComponent } from 'ng-mocks'; | ||
import { EmptyType } from 'app/enums/empty-type.enum'; | ||
import { EnclosureElementType } from 'app/enums/enclosure-slot-status.enum'; | ||
import { EmptyComponent } from 'app/modules/empty/empty.component'; | ||
import { IxTableHarness } from 'app/modules/ix-table/components/ix-table/ix-table.harness'; | ||
import { IxTableModule } from 'app/modules/ix-table/ix-table.module'; | ||
import { | ||
EnclosureHeaderComponent, | ||
} from 'app/pages/system/enclosure/components/enclosure-header/enclosure-header.component'; | ||
import { ElementsComponent } from 'app/pages/system/enclosure/components/views/elements-view/elements.component'; | ||
import { EnclosureStore } from 'app/pages/system/enclosure/services/enclosure.store'; | ||
|
||
describe('ElementsComponent', () => { | ||
let spectator: SpectatorRouting<ElementsComponent>; | ||
let loader: HarnessLoader; | ||
const createComponent = createRoutingFactory({ | ||
component: ElementsComponent, | ||
imports: [ | ||
IxTableModule, | ||
], | ||
params: { | ||
view: 'Voltage Sensor', | ||
}, | ||
declarations: [ | ||
MockComponent(EmptyComponent), | ||
MockComponent(EnclosureHeaderComponent), | ||
], | ||
providers: [ | ||
mockProvider(EnclosureStore, { | ||
enclosureLabel: () => 'M40', | ||
selectedEnclosure: () => ({ | ||
elements: { | ||
[EnclosureElementType.VoltageSensor]: { | ||
45: { | ||
descriptor: '5V Sensor', | ||
status: 'OK', | ||
value: '5.06V', | ||
}, | ||
46: { | ||
descriptor: '12V Sensor', | ||
status: 'OK', | ||
value: '12.01V', | ||
}, | ||
}, | ||
}, | ||
}), | ||
}), | ||
], | ||
}); | ||
|
||
beforeEach(() => { | ||
spectator = createComponent(); | ||
loader = TestbedHarnessEnvironment.loader(spectator.fixture); | ||
}); | ||
|
||
it('renders header with name of the current view', () => { | ||
const header = spectator.query(EnclosureHeaderComponent); | ||
expect(header.title).toBe('Voltage on M40'); | ||
}); | ||
|
||
it('renders enclosure elements for the view route parameter', async () => { | ||
const table = await loader.getHarness(IxTableHarness); | ||
const cells = await table.getCellTexts(); | ||
expect(cells).toEqual([ | ||
['Descriptor', 'Status', 'Value'], | ||
['5V Sensor', 'OK', '5.06V'], | ||
['12V Sensor', 'OK', '12.01V'], | ||
]); | ||
}); | ||
|
||
it('renders an error when view from route param is not available for current enclosure', () => { | ||
spectator.setRouteParam('view', 'Cooling Fan'); | ||
|
||
const empty = spectator.query(EmptyComponent); | ||
expect(empty).toExist(); | ||
expect(empty.conf).toEqual({ | ||
large: true, | ||
message: 'This view is not available for this enclosure.', | ||
title: 'N/A', | ||
type: EmptyType.Errors, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.