Specification for V3BiInfluenceArray
Attributes
| Attribute | Type | Description |
|---|---|---|
items | V3BiInfluenceBase[] | Array of influence base items |
Methods
| Method | Description |
|---|---|
constructor | Initializes a new instance of V3BiInfluenceArray with the provided items array. |
getInfluencerByLanguage | Returns the influence description in the specified language for a given influencer, or ‘undefined stakeholder’ if not found. |
Constructor
Signature:
constructor(items: V3BiInfluenceBase[])
Parameters:
items(V3BiInfluenceBase[]): Array of influence base items.
Description:
The constructor initializes the V3BiInfluenceArray instance with the provided items array.
Method: getInfluencerByLanguage
Signature:
getInfluencerByLanguage(influencer: string, language: string): string
Parameters:
influencer(string): The name or identifier of the influencer.language(string): The language code for which the influencer’s description is requested.
Description:
Returns the influence description in the specified language for a given influencer. If the influencer is not found, it returns ‘undefined stakeholder’.
Example Usage
const influences = [
new V3BiInfluenceBase('influencer1', 'en', 'Influencer description in English'),
new V3BiInfluenceBase('influencer2', 'es', 'Descripción del influencer en español')
];
const influenceArray = new V3BiInfluenceArray(influences);
console.log(influenceArray.getInfluencerByLanguage('influencer1', 'en')); // Output: Influencer description in English
console.log(influenceArray.getInfluencerByLanguage('influencer3', 'fr')); // Output: undefined stakeholder
Scenario Table
| Scenario | Given | When | Then |
|---|---|---|---|
| Create an instance with provided items | The items array contains valid V3BiInfluenceBase objects | I create a new V3BiInfluenceArray with items | The instance should be created with the specified items |
| Return the correct influence description for a given influencer and language | The items array contains valid V3BiInfluenceBase objects | I call getInfluencerByLanguage with a valid influencer and language | The correct influence description for the given influencer and language should be returned |
| Return “undefined stakeholder” if the influencer does not exist | The items array contains valid V3BiInfluenceBase objects | I call getInfluencerByLanguage with an invalid influencer or language | The message ‘undefined stakeholder’ should be returned |
Overview Table
| Attribute | Type | Description |
|---|---|---|
items | V3BiInfluenceBase[] | Array of influence base items |
| Method | Description |
|---|---|
constructor | Initializes a new instance of V3BiInfluenceArray with the provided items array. |
getInfluencerByLanguage | Returns the influence description in the specified language for a given influencer, or ‘undefined stakeholder’ if not found. |
This setup ensures that the V3BiInfluenceArray class is correctly instantiated and that its methods function as expected under various scenarios.