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

Add new API Property - alcohol_prohibition #48

Closed
sthiepaan opened this issue Oct 3, 2020 · 11 comments · Fixed by #57
Closed

Add new API Property - alcohol_prohibition #48

sthiepaan opened this issue Oct 3, 2020 · 11 comments · Fixed by #57
Assignees

Comments

@sthiepaan
Copy link
Collaborator

After short introduction in #32 we decided to extend this package with alcohol_prohibition Property:

  • alcohol_prohibition Property is a one of String
  • Accepted values: "nationwide", "regional", "limited" or "none"
  • For the project needs all new properties will be lowercase.

After adding new property, each Country {Object} should contain:

{
  "country": "poland",
  "capital": "warsaw",
  "currency": "zloty",
  "native_language": ["polish"],
  "famous_for": "pierogi and potatoes",
  "phone_code": "+48",
  "flag": "https://flagpedia.net/data/flags/h80/pl.png",
  "drive_direction": "right",
  // NEW DATA
  "alcohol_prohibition": "none"
},

Additionally there will be new method to use that data:

  • getCountriesByAlcoholProhibition(prohibitionType)
@damn-dvlpr
Copy link
Contributor

Would want to work upon this, was just wondering if I had to manually update every field in data.json? or is there other things developers do?

@sthiepaan
Copy link
Collaborator Author

@damn-dvlpr since we collect that data and let API consumers use it, we need to provide it. Because of that, there are 3 things that have to be done:

  1. Fill the data
  2. Create new (or modify existing ones) methods to consume data
  3. Write/Update tests for the methods

You can check some of Pull Requests to see more details.

@damn-dvlpr
Copy link
Contributor

Alright! would start working upon it.

@damn-dvlpr
Copy link
Contributor

@sthiepaan i have made a pull request #57 implementing this, can you please review it.
also, i have never written tests, was wondering if you can guide me through the procedure of it. Thanks.

@sthiepaan
Copy link
Collaborator Author

sthiepaan commented Oct 5, 2020

@damn-dvlpr thanks you, I will have a look at it soon.

i have never written tests, was wondering if you can guide me through the procedure of it. Thanks.

First of all you need to be a little bit fammiliar with Jasmine Framework. Then you can go to spec/getCountriesSpec.js where all tests are located. In general, what you need to do, is prepare a function, that use our API and compare its result with what you expect. For example:

// ...
describe("The getAllCountries", () => {
  it("returns all of the countries", () => {
    expect(countryApi.getAllCountries().length).toEqual(196);
  });
});
// ...

is a test case that check if the getAllCountries() Method returns all Country {Object} (which is 196 countries).
After you write a test, you can execute it by running in terminal npm test Script.

Hope this gives you better overview! ✌️

PS: If you put an id of issue into description of Pull Request, it will be automatically mentioned on the issue itself. You can check one of my PRs to see how I do this, to make readable PR description 😉

@damn-dvlpr
Copy link
Contributor

Alright, will be doing it today. Btw, the tests are currently broken cause someone added the "drive direction" attritube and didn't update the tests for the same. Would fix that too.

@sthiepaan
Copy link
Collaborator Author

@damn-dvlpr I had no error at all when I ran tests. What error did you have?

@damn-dvlpr
Copy link
Contributor

Oh! i am really sorry, guess the fails are because of mine added fields

@sthiepaan
Copy link
Collaborator Author

sthiepaan commented Oct 6, 2020

This is actually why tests are awesome! 😉 They let you control the state of your code whether it still works properly or something unexpected happen. If we don't have a tests and extend some stuff, we might be in a situation where something is broken on production code.

In that case, because you added new properties, you need to update tests, so they have proper expected values.

@damn-dvlpr
Copy link
Contributor

I think the PR is ready to be merged, please review it.

@damn-dvlpr
Copy link
Contributor

Also, thanks for the "PR description" suggestions, learned a new and cleaner way today!

@sthiepaan sthiepaan linked a pull request Oct 18, 2020 that will close this issue
8 tasks
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 a pull request may close this issue.

2 participants