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

Initial Tests #244

Closed
5 of 9 tasks
raineorshine opened this issue Dec 28, 2019 · 5 comments
Closed
5 of 9 tasks

Initial Tests #244

raineorshine opened this issue Dec 28, 2019 · 5 comments
Labels
test Testing and project configuration

Comments

@raineorshine
Copy link
Contributor

raineorshine commented Dec 28, 2019

Create the following tests:

  • 1. New Thought
    • When the user hits Enter, a new thought is created:
    • getThought('') should return a thought object in the root context.
    • getThoughtsRanked([ROOT_TOKEN]) should contain only ''
    • An empty thought should be rendered in the DOM
    • localForage should be updated with the new thought
  • 2. Edit Thought
    • When the user creates a new thought and types 'A', the empty thought should be modified:
    • '' should not exist
    • getThought('A') should return a thought object in the root context.
    • getThoughtsRanked([ROOT_TOKEN]) should contain only 'A'
    • A thought with text "A" should be rendered in the DOM
    • localForage should be updated with the new thought
  • 3. New Subthought
    • When the user creates a new thought, types 'A', and hits Cmd + Enter a new subthought should be created:
    • getThought('A') should return a thought object in the root context.
    • getThought('') should return a thought object in the 'A' context.
    • getThoughtsRanked([ROOT_TOKEN]) should contain only 'A'
    • getThoughtsRanked(['A']) should contain only ''
    • An empty subthought should be rendered under "A" in the DOM
    • localForage should be updated with the new thought
  • 4. newThoughtAbove
    • Test getThought, getThoughtsRanked, DOM, and localForage as above.
  • 5. newThoughtTop
    • Test getThought, getThoughtsRanked, DOM, and localForage as above.
  • 6. newUncle
    • Test getThought, getThoughtsRanked, DOM, and localForage as above.
  • 7. setCursor
    • When the user clicks a thought, the cursor is moved to that thought.
  • 8. expandThoughts
    • When the user clicks on a collapsed thought, the thought should be expanded to reveal its subthoughts.
  • 9. deleteThought
@mekanix
Copy link
Contributor

mekanix commented Dec 28, 2019

Problems during testing:

  1. import * as uuid vs import uuid mekanix@86b5d90#diff-b056c1ad802eb5041886154caaf3a3d4R3
  2. window and document objects in testing are not complete, so document.getSelection() in https://github.com/mekanix/em/blob/feature/jest/src/components/ModalComponent.js#L61 doesn't work

For 1. what was observed that "uuid" is function in browser but object in testing. It took me way too much time to suspect that "import" is not working. There might be other errors like this, but I'm stuck on 2. For 2. there are 2 ways we can take: mock missing functions or store selection in store. If we decide to mock, these are the references:

@raineorshine
Copy link
Contributor Author

@mekanix Thanks! Great work.

  1. What's the easiest way to simply ignore the browser selection in tests? Dummy mock? Some day we may want to test selection position, but at this point it is a low priority.

@mekanix
Copy link
Contributor

mekanix commented Dec 28, 2019

It's case by case. Sometimes we can just return dummy value, sometimes we must return something more meaningful, depending on what the rest of the code does.

@raineorshine
Copy link
Contributor Author

Okay, thanks. I don't have a strong opinion in this case, so take the simplest approach when possible and use your judgment.

@raineorshine raineorshine added the test Testing and project configuration label Mar 22, 2020
@raineorshine
Copy link
Contributor Author

Most tests implemented in #706.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Testing and project configuration
Projects
None yet
Development

No branches or pull requests

2 participants