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

test: Add tests for QueryEngine and utils for query package. #55

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Ta5r
Copy link
Contributor

@Ta5r Ta5r commented Feb 11, 2025

What

  • This PR adds jest tests for testing of the QueryEngine present in the snapwp/query package.
  • This PR also tests the parse-template and parse-global-styles utils present.

Why

  • This PR is necessary to fully validate the correct setup of QueryEngine, particularly ensuring that it initializes only once and correctly configures the Apollo Client.
  • The parseQueryResult functions for templates and global styles needed test cases to verify correct data parsing and error handling.

Related Issue(s):

How

  • Adds assertions to verify QueryEngine initializes correctly and remains a singleton.
  • Adds tests for parseQueryResult functions by:
    • Validating successful parsing of template and global styles data.
    • Ensuring errors are logged and thrown correctly when data is missing or invalid.

Testing Instructions

  • Run :
npm run test:unit

Screenshots

Screenshot 2025-02-11 at 4 37 13 PM

Additional Info

NA

Checklist

  • I have read the Contribution Guidelines.
  • My code is tested to the best of my abilities.
  • My code passes all lints (ESLint, tsc, prettier etc.).
  • My code has detailed inline documentation.
  • I have added unit tests to verify the code works as intended.
  • I have updated the project documentation accordingly.

@Ta5r Ta5r requested a review from SH4LIN February 11, 2025 10:58
@Ta5r Ta5r self-assigned this Feb 11, 2025
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.

1 participant