Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

488 - Add latest date validation for date answers #124

Merged
merged 1 commit into from
Sep 19, 2018

Conversation

tgandrews
Copy link
Contributor

@tgandrews tgandrews commented Sep 14, 2018

What is the context of this PR?

Adds the ability to hold latest date validations against date answers.

How to review

Reading

Given you have a date answer with an ID of 19

query QuestionPage($id: ID!) {
  answer(id: $id) {
    id
    ... on BasicAnswer {
      validation {
        ... on DateValidation {
          latestDate {
            id
            enabled
            custom
            offset {
              value
              unit
            }
            relativePostion
          }
        }
      }
    }
  }
}

Input:

{ "id": 19 }

Updating

Given you have an latest date validation with ID 35

mutation updateValidation($input: UpdateValidationRuleInput!) {
  updateValidationRule(input: $input) {
    id
    enabled
    ... on LatestDateValidationRule {
      custom
      offset {
        value
        unit
      }
      relativePostion
    }
  }
}

Input:

{
  "input":{
    "id": 35,
    "latestDateInput": {
      "offset": {
        "value": 10,
        "unit": "Months"
      },
      "relativePostion": "After",
      "custom": "2017-01-01"
    }
  }
}

Dependencies

@tgandrews
Copy link
Contributor Author

},
relativePosition: "After"
};
expect(JSON.parse(JSON.stringify(result))).toMatchObject(expected);
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be simplified to: expect(result).toMatchObject(expected);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This works if the test passes but if the objects don't match then you can get jestjs/jest#6730

This makes the error more readable when the test fails. I have added a comment and a tech debt ticket. https://trello.com/c/Ho4Rh8MH/333-resolver-tests-can-trigger-bug-in-jest

Copy link
Contributor

@samiwel samiwel left a comment

Choose a reason for hiding this comment

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

LGTM

@tgandrews tgandrews merged commit 5da3ff2 into master Sep 19, 2018
@tgandrews tgandrews deleted the 488-latest-date-validation branch September 19, 2018 07:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants