Skip to content

"accepts search params in the querystring" test fails on nested fields #111

Description

@sgentle

I have a candidates schema with a field contactDetails containing an object. The test named in the issue uses this logic to determine a field to query with:

const property = Object.keys(record).filter(k => k !== 'id')[0];

Which selects contactDetails, but appears to be unable to turn that into a query string which works.

Error:

  1) candidate model GET /candidates accepts search params in the querystring:

      AssertionError: [] must be equivalent to [{"address1":"94864 Grant Field","country":"New Caledonia","email":"Sofia_Reilly29@yahoo.com","phone":"601.689.4664","postcode":"43086-2527","state":"New Magdalen","suburb":"Cartwrighthaven"}]
      + expected - actual

      -[]
      +[
      +  {
      +    "address1": "94864 Grant Field"
      +    "country": "New Caledonia"
      +    "email": "Sofia_Reilly29@yahoo.com"
      +    "phone": "601.689.4664"
      +    "postcode": "43086-2527"
      +    "state": "New Magdalen"
      +    "suburb": "Cartwrighthaven"
      +  }
      +]

Relevant schema section:

    "contactDetails": {
      "description": "The contact details of the Candidate",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "email",
        "address1",
        "suburb",
        "postcode",
        "state",
        "country",
        "phone"
      ],
      "properties": {
        "email": {
          "description": "The candidate's email address",
          "type": "string",
          "example": "hello@me.com",
          "faker": "internet.email"
        },
        "address1": {
          "description": "First line of the candidate's address",
          "type": "string",
          "example": "Level 10",
          "faker": "address.streetAddress"
        },
        "address2": {
          "description": "First line of the candidate's address",
          "type": "string",
          "example": "191 Fake Street",
          "faker": "address.secondaryAddress"
        },
        "suburb": {
          "description": "Suburb or city of the candidate's address",
          "type": "string",
          "example": "Hillsville",
          "faker": "address.city"
        },
        "postcode": {
          "description": "Postcode of the candidate's address",
          "type": "string",
          "example": "1234",
          "faker": "address.zipCode"
        },
        "state": {
          "description": "State of the candidate's address",
          "type": "string",
          "example": "NSW",
          "faker": "address.city"
        },
        "country": {
          "description": "Country of the candidate's address",
          "type": "string",
          "example": "Australia",
          "faker": "address.country"
        },
        "phone": {
          "description": "Phone number of the candidate",
          "type": "string",
          "example": "0411111111",
          "faker": "phone.phoneNumber"
        }
      }
    }

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions