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

Unit Tests - Status Endpoint #35

Open
Vanethos opened this issue Aug 14, 2019 · 2 comments
Open

Unit Tests - Status Endpoint #35

Vanethos opened this issue Aug 14, 2019 · 2 comments
Assignees
Labels
hacktoberfest Hacktoberfest is here! Don't know which issues you should choose? Pick these!

Comments

@Vanethos
Copy link
Contributor

Vanethos commented Aug 14, 2019

Description
Unit tests for the endpoint GET {{base_url}}/occurrences/statuses

Pre-Requisites

Unit-Tests

  • Creating the model via a JSON Response
{
    "links": {
        "first": "https://api.vost.pt/v1/occurrences/statuses?page%5Bsize%5D=1&sort=created_at&order=desc&page%5Bnumber%5D=1",
        "last": "https://api.vost.pt/v1/occurrences/statuses?page%5Bsize%5D=1&sort=created_at&order=desc&page%5Bnumber%5D=10",
        "next": "https://api.vost.pt/v1/occurrences/statuses?page%5Bsize%5D=1&sort=created_at&order=desc&page%5Bnumber%5D=2"
    },
    "data": [
        {
            "type": "occurrence_statuses",
            "id": "10",
            "attributes": {
                "code": 255,
                "name": "Encerrada pela VOST",
                "created_at": "2019-07-02 13:31:18",
                "updated_at": "2019-07-02 13:31:18"
            }
        }
    ],
    "meta": {
        "items": 1,
        "total": 10
    }
}
  • Calling the endpoint and mocking a 200 response with a valid response
  • Calling the endpoint and mocking a 200 response with an invalid response
  • Calling the endpoint and mocking a 400 response
  • Verify that calling the api with a mock response creates the expected object
@OldMetalmind OldMetalmind added this to the v1.0.0 - Akita milestone Aug 16, 2019
@Vanethos Vanethos added the hacktoberfest Hacktoberfest is here! Don't know which issues you should choose? Pick these! label Oct 17, 2019
@pidwid
Copy link

pidwid commented Oct 18, 2019

ill do this issue, can you please elaborate it a little more.

@Vanethos
Copy link
Contributor Author

Hi @pidwid I'll assign the issue to you

You will need to do a series of tests:

  • First, use the values provided in the json to create a StatusModel object, serialize it and compare it to the json provided in the description
  • Then, you will need to verify that the StatusService class can fetch data from the server and return a correct object. To do that, you will need to creat a new instance of dio with an adapter ( see https://github.com/vostpt/mobile-app/blob/develop/test/utils/dioadapter/parishes_endpoint_adapter.dart for how to do this) and then you will need to test:
    -- Mock a 200 response with a valid json object, and you need to test it with an expected object (see the first test to get an idea how to do it)
    -- Mock a 200 response with an invalid json and check that it throws an error
    -- Mock a 400 response and check that it throws an error.

If you need any more instructions please do tell

I'll try to have an example for comparison as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Hacktoberfest is here! Don't know which issues you should choose? Pick these!
Projects
None yet
Development

No branches or pull requests

3 participants