Skip to content

Adding currency rate for the central bank of Iceland#494

Open
olafurorng wants to merge 2 commits into
apis-is:masterfrom
olafurorng:currency/central-bank
Open

Adding currency rate for the central bank of Iceland#494
olafurorng wants to merge 2 commits into
apis-is:masterfrom
olafurorng:currency/central-bank

Conversation

@olafurorng

@olafurorng olafurorng commented Mar 26, 2020

Copy link
Copy Markdown

Adding a new source for the currency endpoint: the currency rate from the Central Bank of Iceland.

Checklist

  • Write tests
  • Write documentation

@olafurorng

Copy link
Copy Markdown
Author

@olafurorng

Copy link
Copy Markdown
Author

@olafurorng

Copy link
Copy Markdown
Author

Comment thread endpoints/currency/cb.js
Comment on lines +21 to +27
const name = tds.eq(0).text()

if (name) {
currencies.push({
shortName: name,
longName: tds.eq(1).text(),
value: tds.eq(4).text(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the html has changed. The table only has 3 columns now so the indexes in the tds.eq calls are wrong.

Suggested change
const name = tds.eq(0).text()
if (name) {
currencies.push({
shortName: name,
longName: tds.eq(1).text(),
value: tds.eq(4).text(),
const name = tds.eq(1).text()
if (name) {
currencies.push({
shortName: name,
longName: tds.eq(0).text().trim(),
value: Number(tds.eq(2).text().replace(',', '.')),

I'm not sure if the if on line 23 is still valid now that name is from column index 1.

it('should return an array of objects containing correct fields', (done) => {
const params = helpers.testRequestParams('/currency/cb')
const resultHandler = helpers.testRequestHandlerForFields(done, fieldsToCheckFor)
request(params, resultHandler)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing mock data for this test.

Here's an example of how to do it: https://github.com/apis-is/apis/blob/1fb161a/endpoints/horses/tests/integration_test.js#L22-L4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants