- Angular CLI Version: 15.2.8
- Angular Core Version: 15.2.8
- Default Port: 8000
The application has 2 components:
- The
ResourceTable
component, which displays the list of resources in a tabular form. - The
ResourceDetails
component, which presents the full details of the selected resource.
The application has the following functionalities:
- Initially, the
ResourceTable
displays entire list of resources is a tabular format. The list of resources is passed to it as input which is an array ofResource
type objects. TheResource
type has below interface:
interface Resource {
name: string;
country: string;
id: string; // Unique identifier of each resource
}
-
Each resource row in this table has columns for
name
,country
, andView details
button. Clicking onView details
button selects this resource, and displays the details of the selected resource inResourceDetails
component. -
The details of the resource is defined in
ResourceDetails
interface:
interface ResourceDetails {
id: string;
city: string;
pin: number;
state: string;
totalCapacity: number;
allocated: number;
}
-
The
ResourceDetails
component renders following columns -name
,country
,city
,state
,pin
,totalCapacity
, andallocated
. It should render only single resource at a time which is most recently selected. -
You need to merge data from both interfaces to render it in
ResourceDetails
component. -
Since no resource is selected initially,
ResourceDetails
component should not be rendered.
The following data-test-id attributes are required in the component for the tests to pass:
- The
ResourceTable <tbody>
has the data-test-id attributeresource-list
. - Each
View details
button has the data-test-id attributeview-details-button
. - The
ResourceDetails <tbody>
has the data-test-id attributeresource-details
.
Read-only Files
- src/app/app.component.spec.ts
Commands
- run:
npm start
- install:
npm install
- test:
npm test