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

tests: add all timing edge cases #158

Merged
merged 7 commits into from
Sep 22, 2024

Conversation

cirex-web
Copy link
Collaborator

@cirex-web cirex-web commented Sep 9, 2024

Description

Adds everything mentioned in https://github.com/ScottyLabs/dining-api/wiki/Timing-Cases.
This does not pass with the code as-is, but should probably be merged before the refactor PR
image

I mocked out the Axios GET endpoint and replaced it with partly dynamically generated HTML files meant to simulate the real dining pages. A lot of this has been abstracted away (see mockAxios.ts and mockTimings.ts) with the goal of cleaner tests like the following:

  test("overlapping/self-containing times", async () => {
    setUpTimingTest({
      [Mon]: "8:00 AM - 4:00 PM, 2:00 PM - 9:00 PM",
      [Tue]: "2:00 PM - 9:00 PM, 8:00 AM - 4:00 PM",
      [Wed]: "8:00 AM - 9:00 PM, 2:00 PM - 4:00 PM",
      [Thur]: "2:00 PM - 4:00 PM, 8:00 AM - 9:00 PM",
      [Fri]: "7:00 AM - 4:00 PM, 6:00 AM - 2:00 PM, 7:00 PM - 12:00 AM",
    });
    await queryParserAndAssertTimingsCorrect([
      [Mon, 8, 0, Mon, 21, 0],
      [Tue, 8, 0, Tue, 21, 0],
      [Wed, 8, 0, Wed, 21, 0],
      [Thur, 8, 0, Thur, 21, 0],
      [Fri, 6, 0, Fri, 16, 0],
      [Fri, 19, 0, Fri, 23, 59],
    ]);
  });

With these added tests, we can be more confident that future code changes won't break existing parsing functionality.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Test A
  • Test B

Test Configuration:

  • Node.js version:
  • Python version:
  • Desktop/Mobile:
  • OS:
  • Browser:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link

vercel bot commented Sep 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dining-api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 22, 2024 11:26pm

@cirex-web
Copy link
Collaborator Author

cirex-web commented Sep 10, 2024

the test code is a bit unreadable at the moment... I'll fix it soon
Fixed

@cirex-web cirex-web marked this pull request as draft September 10, 2024 03:00
Copy link
Member

@GhostOf0days GhostOf0days left a comment

Choose a reason for hiding this comment

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

I see no issues. Thanks for your PR.

@GhostOf0days GhostOf0days merged commit dde5777 into ScottyLabs:main Sep 22, 2024
2 of 3 checks passed
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.

2 participants