-
Notifications
You must be signed in to change notification settings - Fork 783
test: added tests for notifications reducer #567
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: added tests for notifications reducer #567
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jglover thanks for this PR, I think it's pretty clear and well written.
I have 2 things I'd like to see changed here:
- Try not to use relative imports
- Avoid nested describes for your tests
Besides that, LGTM.
@@ -1,8 +1,8 @@ | |||
import React from 'react'; | |||
import { shallow } from 'enzyme'; | |||
|
|||
import organization from '../../data/organization'; | |||
import user from '../../data/user'; | |||
import organization from '../../data/api/organization'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we can use absolute imports instead of relative imports? Relative imports can get messy pretty quick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This occurred to me, I'll update it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm we're still using relative imports here.
@@ -0,0 +1,475 @@ | |||
import React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally speaking, I agree with @andrewda about not nesting describes, that can get quite messy pretty quickly.
I think one describe per test suite is fine and just using it
clauses should be enough for describing a good test suite. Can you please flatten your tests so you only use 1 describe and multiple it
statements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
import { notification } from '../../data/api/notification'; | ||
import { authError } from '../../data/api/error'; | ||
|
||
describe('Notifications reducer', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use title case: "Notifications Reducer".
@alejandronanez @andrewda The requested changes have been made :) |
@@ -1,8 +1,8 @@ | |||
import React from 'react'; | |||
import { shallow } from 'enzyme'; | |||
|
|||
import organization from '../../data/organization'; | |||
import user from '../../data/user'; | |||
import organization from '../../data/api/organization'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm we're still using relative imports here.
import { | ||
closed as closedPr, | ||
open as openPr, | ||
merged as mergedPr, | ||
} from '../../data/pull-request'; | ||
} from '../../data/api/pull-request'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we're using relative imports here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are just tests I touched when I moved the test data files, my discipline tells me update all tests in a different PR but I'll do it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alejandronanez all references updated to use alias instead of absolute paths.
…git-point into add-notifications-reducer-tests
@alejandronanez updated paths to use alias instead of absolute paths across all tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jglover !
Thanks! |
Added tests for notifications reducer. This revealed a few problems with the reducer that I'll address in an issue.