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

Adds events class and specs #1194

Merged
merged 2 commits into from
Mar 9, 2017
Merged

Adds events class and specs #1194

merged 2 commits into from
Mar 9, 2017

Conversation

el-mapache
Copy link
Contributor

@el-mapache el-mapache commented Mar 8, 2017

Why: multiple js components will need an event emitter, separate
class is easier to test, more robust than initial implementation

Just a little bit of refactoring, feedback welcome!

@el-mapache el-mapache self-assigned this Mar 8, 2017
@el-mapache el-mapache force-pushed the ab-event-class branch 3 times, most recently from b23cf3d to 22e99bc Compare March 8, 2017 23:46
**Why**: multiple js components will need an event emitter, separate
class is easier to test, more robust than initial implementation
events = new Events();
});

it('maintains a on object of to store handlers', () => {
Copy link
Member

Choose a reason for hiding this comment

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

This test description is unclear to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah that is super unclear! I think mangled it by deleting parts of it and trying to rewrite it...

**Why**: What was there didn't make any sense.
@el-mapache
Copy link
Contributor Author

@hursey013 Updated the spec description to be clearer!

Copy link
Member

@hursey013 hursey013 left a comment

Choose a reason for hiding this comment

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

Looks good! Will the events class be able to used with the Modal component as well?

@@ -0,0 +1,89 @@
const Events = require('../../../../app/assets/javascripts/app/utils/events').default;
/*eslint-disable */
const sinon = require('sinon');
Copy link
Member

Choose a reason for hiding this comment

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

Sinon looks cool, do you think we should start moving in this direction for javascript tests? I tend to rely on feature specs but I know that's probably not the right way if we continue to add more javascript.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think we definitely want to be unit testing our javascript where possible. Self contained classes that don't have explicit dependencies on the DOM or browser APIs are great candidates for that.

@el-mapache
Copy link
Contributor Author

It will! I'm going to put in a PR today that does that.

@el-mapache el-mapache merged commit 3964384 into master Mar 9, 2017
@el-mapache el-mapache deleted the ab-event-class branch March 9, 2017 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants