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

Better tests for lib/sort.js #300

Open
dreeves opened this issue Oct 17, 2018 · 0 comments
Open

Better tests for lib/sort.js #300

dreeves opened this issue Oct 17, 2018 · 0 comments

Comments

@dreeves
Copy link
Contributor

dreeves commented Oct 17, 2018

Now that we've refactored the gallery sorting code to compute a sort index for every promise and sort by that single number, we could make the tests simpler by dropping the need for pairwise comparisons.

Instead just define a big list of different kinds of promises, listed in the order they ought to be in in a user's gallery. Then just compute the sort index for each promise and check that those numbers are sorted in ascending order.

Relevant types of promises, listed in the order they should sort in:

  1. tini and tdue and tfin all null (or undefined?)
  2. tini a week ago and tdue and tfin both null
  3. tini a day ago and tdue and tfin both null
  4. tini is anything, tdue is today, tfin is null [scheldist 0]
  5. tini is anything, tdue is 2 days ago, tfin is null [scheldist 1]
  6. tini is anything, tdue is 2 days from now, tfin is null [scheldist 2]
  7. tini is anything, tdue is 4 days ago, tfin is null [scheldist 3]
  8. tini is anything, tdue is 4 days from now, tfin is null [scheldist 4]
  9. tini is anything, tdue is 12 days ago, tfin is null [scheldist 5]
  10. tini is anything, tdue is 24 days ago, tfin is null [scheldist 6]
  11. tini is anything, tdue is 7 days from now, tfin is null [scheldist 7]
  12. tini is anything, tdue is anything, tfin is yesterday
  13. tini is anything, tdue is anything, tfin is a week ago

So number 1 is a promise that's messed up and should sort to the very top, next are numbers 2-3 which sort by increasing creation date because they have no due dates, after that are numbers 4-11 which are incomplete promises sorted by urgency (Schelling distance), and finally numbers 12-13 are completed promises sorted by decreasing completion date.

For the "is anything" values it shouldn't matter to the sorting how those are filled in so just pick random dates and make some of them are null to ensure that doesn't break anything either.

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

No branches or pull requests

1 participant