Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made EMEA default in RNANews #25

Merged
merged 4 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/RNANews/RNANewsConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import MorningstarURL from '../Shared/MorningstarURL';
import RNANewsOptions from './RNANewsOptions';
import RNANewsConverter from './RNANewsConverter';
import RNANewsJSON from './RNANewsJSON';
import MorningstarRegion from '../Shared/MorningstarRegion';


/* *
Expand Down Expand Up @@ -103,6 +104,13 @@ export class RNANewsConnector extends MorningstarConnector {

this.converter = new RNANewsConverter(options.converter);
this.options = options;

if (this.options.api?.url === undefined) {
this.options.api = {
...this.options.api ?? {},
bre1470 marked this conversation as resolved.
Show resolved Hide resolved
url: MorningstarRegion.baseURLs['EMEA']
};
}
}


Expand Down
26 changes: 26 additions & 0 deletions test/unit-tests/RNANews/RNANewsConverter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,29 @@ export function rnaNewsValidation () {
'Mock response should be considered a valid response'
);
}

export function rnaNewsUrlShouldBeEMEA () {

const connector = new MC.RNANewsConnector({});

Assert.equal(
connector.options.api?.url,
'https://www.emea-api.morningstar.com/',
'Connector options should override url to be emea if api options are not provided'
);
}

export function rnaNewsUrlShouldNotOverrideIfAPIOptionsAreProvided () {

const connector = new MC.RNANewsConnector({
api: {
url: 'https://www.us-api.morningstar.com/'
}
});

Assert.equal(
connector.options.api?.url,
'https://www.us-api.morningstar.com/',
'Connector options should not override url to be emea if api options are provided'
);
}