Skip to content

test: Added tests for auth reducer and refactored some other tests #579

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 6 commits into from
Oct 29, 2017

Conversation

jglover
Copy link
Contributor

@jglover jglover commented Oct 25, 2017

Adds test for auth reducer and refactoring.
Also adds default fallback for 'en' inside localization-helper incase location cannot be determined/promise to get locale in app.js has not fulfilled yet and somehow user has navigated, requiring a value (this was breaking unit tests).

@coveralls
Copy link

Coverage Status

Coverage increased (+2.7%) to 33.584% when pulling 09d659f on jglover:tests/auth-reducer-tests into a43d3bc on gitpoint:master.

Copy link
Member

@andrewda andrewda left a comment

Choose a reason for hiding this comment

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

End tests in .js, not .spec.js. Besides that looks good.

@andrewda
Copy link
Member

Also - don't end data files in .data.js. If we're going to change the extensions for the files, we should do it in a new PR. For now keep things consistent.

@andrewda
Copy link
Member

There's a lot of data in data/api/users.data.js file. Maybe we could shorten it down to 1 event per type so it's easier to follow if something breaks?

@andrewda andrewda mentioned this pull request Oct 25, 2017
63 tasks
@jglover
Copy link
Contributor Author

jglover commented Oct 25, 2017

I'll rename those files, yeah it's quite a bit of data; I just took the GitHub example responses verbatim from the API docs. Since the file isn't used in a build is it a good idea to just keep data as a copy of the example responses incase it ever needs to be changed?

@jglover
Copy link
Contributor Author

jglover commented Oct 26, 2017

@andrewda done. What's the reasoning behind not using *.spec.js though? I'm curious about that one, it's the accepted convention in just about every framework or project I've worked with and helps differentiate the file when using fuzzy search, triggers test syntax highlighting in most editors etc

@coveralls
Copy link

Coverage Status

Coverage increased (+2.3%) to 36.801% when pulling f042ae5 on jglover:tests/auth-reducer-tests into 6567aa3 on gitpoint:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.3%) to 36.801% when pulling f042ae5 on jglover:tests/auth-reducer-tests into 6567aa3 on gitpoint:master.

@andrewda
Copy link
Member

@jglover Several reasons: 1) when I began adding tests, I didn't use it, and we've stayed consistent with that, 2) everything's already in a single __tests__/ directory, so it's not really necessary to define something as a specification. That being said, I'd love to completely redo our test naming scheme in another PR (an issue for discussion would be great, too).

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.

Besides @andrewda changes. LGTM

@@ -8,7 +8,8 @@ export const translate = (key, locale, interpolation = null) =>
I18n.t(key, { locale, ...interpolation });

export const getLocale = () => {
const locale = I18n.locale.toLowerCase();
// If for some reason a locale cannot be determined, fall back to 'en'.
const locale = (I18n.locale && I18n.locale.toLowerCase()) || 'en';
Copy link
Member

Choose a reason for hiding this comment

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

💯

Copy link
Member

Choose a reason for hiding this comment

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

@jglover Please read en from src/config/common, as well as the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chinesedfan good tip, updated.

@jglover
Copy link
Contributor Author

jglover commented Oct 29, 2017

@andrewda Anything left outstanding? Keen to get this merged before it gets conflicts.

@@ -8,7 +8,8 @@ export const translate = (key, locale, interpolation = null) =>
I18n.t(key, { locale, ...interpolation });

export const getLocale = () => {
const locale = I18n.locale.toLowerCase();
// If for some reason a locale cannot be determined, fall back to 'en'.
const locale = (I18n.locale && I18n.locale.toLowerCase()) || 'en';
Copy link
Member

Choose a reason for hiding this comment

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

@jglover Please read en from src/config/common, as well as the comment.

@coveralls
Copy link

Coverage Status

Coverage increased (+4.9%) to 39.359% when pulling bc82b7f on jglover:tests/auth-reducer-tests into 6567aa3 on gitpoint:master.

@andrewda andrewda merged commit 2fda53e into gitpoint:master Oct 29, 2017
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