Skip to content

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

Merged
merged 8 commits into from
Oct 25, 2017

Conversation

jglover
Copy link
Contributor

@jglover jglover commented Oct 23, 2017

Added tests for notifications reducer. This revealed a few problems with the reducer that I'll address in an issue.

@jglover jglover mentioned this pull request Oct 23, 2017
63 tasks
Copy link
Member

@alejandronanez alejandronanez left a 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';
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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';
Copy link
Member

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?

Copy link
Contributor Author

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', () => {
Copy link
Member

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".

@coveralls
Copy link

Coverage Status

Coverage increased (+3.1%) to 32.873% when pulling f6f8445 on jglover:add-notifications-reducer-tests into 5e33fee on gitpoint:master.

jglover added a commit to jglover/git-point that referenced this pull request Oct 24, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+3.004%) to 33.719% when pulling 6653325 on jglover:add-notifications-reducer-tests into 0f7accc on gitpoint:master.

@jglover
Copy link
Contributor Author

jglover commented Oct 25, 2017

@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';
Copy link
Member

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';
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@coveralls
Copy link

Coverage Status

Coverage increased (+3.0%) to 33.832% when pulling c100519 on jglover:add-notifications-reducer-tests into a43d3bc on gitpoint:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+3.0%) to 33.832% when pulling c100519 on jglover:add-notifications-reducer-tests into a43d3bc on gitpoint:master.

@jglover
Copy link
Contributor Author

jglover commented Oct 25, 2017

@alejandronanez updated paths to use alias instead of absolute paths across all tests.

Copy link
Member

@alejandronanez alejandronanez left a comment

Choose a reason for hiding this comment

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

Thanks @jglover !

@andrewda andrewda merged commit 3c78a80 into gitpoint:master Oct 25, 2017
@andrewda
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

5 participants