Skip to content

Use async/await in auth store, added tests#88

Open
ljones92 wants to merge 2 commits into
realworld-apps:masterfrom
ljones92:auth-async-await
Open

Use async/await in auth store, added tests#88
ljones92 wants to merge 2 commits into
realworld-apps:masterfrom
ljones92:auth-async-await

Conversation

@ljones92

Copy link
Copy Markdown

Addresses issue #58

@ljones92

Copy link
Copy Markdown
Author

This also addresses #65 #67 and #68 as well by the looks of it but I can revert those changes if necessary

Comment thread tests/unit/store/auth.module.spec.js Outdated
});

it("SET_AUTH", () => {
const stub = sinon.stub(JwtService, "saveToken");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We do not need sinon here. Jest is capable of mocking JavaScript.

Resources

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point, too used to the mocha+sinon combo

Comment thread src/store/auth.module.js Outdated
};

const getters = {
export const getters = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do we export this now?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point, I'll remove these exports

Comment thread src/store/auth.module.js Outdated
async [LOGIN](context, credentials) {
try {
const {
data: { user = {} }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we keep Object destructuring at one level? Otherwise, it gets unreadable.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I tend to quite like nested destructuring since it allows you to easily assign default values without having to do a separate check at each level and assign new variable names. I accept that it can make it a bit less readable for people not used to it though so I'll simplify it.

Comment thread src/store/auth.module.js Outdated
};

const mutations = {
export const mutations = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I do not think we need to export this

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants