-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
BaseService: make serviceData and badgeData explicit and declarative #1451
Conversation
Generated by 🚫 dangerJS |
colorA: makeColor(overrideColorA), | ||
}; | ||
const color = makeColor(overrideColorB || serviceColor || defaultColor || 'lightgrey'); | ||
setBadgeColor(badgeData, color); |
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 duplicates code in makeBadgeData
but ultimately will replace it. I don't think it makes sense to reuse that function here; it just makes the code harder to reason about and more roundabout.
To make this even cleaner, we could rewrite some of these helper functions and/or change the interface to makeBadge
.
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.
I like your idea to extract _makeBadgeData
, code looks much better now. Would you like to add more tests?
@@ -24,6 +24,29 @@ class DummyService extends BaseService { | |||
} | |||
|
|||
describe('BaseService', () => { | |||
describe('_makeBadgeData', function () { |
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.
We have all cases with text
tested here and that's great! Would you like to add tests for other properties? There's a lot of code connected to colors which isn't tested 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.
Yea, I'd love to add more tests, though maybe we can merge this and tag-team the tests. There is plenty of untested functionality here.
…1543 This merges the `node-8` branch. The heavy lift was by @Daniel15 with refactoring from me and a patch by @RedSparr0w. * New API for registering services (#963) * Disable Node 6 tests on node-8 branch (#1423) * BaseService: Factor out methods _regex and _namedParamsForMatch (#1425) - Adjust test grouping - Rename data -> queryParams, text -> message * BaseService tests: Use Chai (#1450) * BaseService: make serviceData and badgeData explicit and declarative (#1451) * fix isValidStyle test (#1544) * Run tests in Node 9, not Node 6 (#1543)
Based on feedback in #1425.
@platan @RedSparr0w