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

BaseService: make serviceData and badgeData explicit and declarative #1451

Merged
merged 2 commits into from
Jan 19, 2018
Merged

BaseService: make serviceData and badgeData explicit and declarative #1451

merged 2 commits into from
Jan 19, 2018

Conversation

paulmelnikow
Copy link
Member

Based on feedback in #1425.

@platan @RedSparr0w

@shields-ci
Copy link

shields-ci commented Jan 15, 2018

Warnings
⚠️

This PR modified helper functions in lib/ but not accompanying tests. That's okay so long as it's refactoring existing code.

Messages
📖

✨ Thanks for your contribution to Shields, @paulmelnikow!

Generated by 🚫 dangerJS

@paulmelnikow paulmelnikow added the core Server, BaseService, GitHub auth, Shared helpers label Jan 15, 2018
colorA: makeColor(overrideColorA),
};
const color = makeColor(overrideColorB || serviceColor || defaultColor || 'lightgrey');
setBadgeColor(badgeData, color);
Copy link
Member Author

@paulmelnikow paulmelnikow Jan 15, 2018

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.

Copy link
Member

@platan platan left a 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 () {
Copy link
Member

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.

Copy link
Member Author

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.

@paulmelnikow paulmelnikow merged commit ade62fc into badges:node-8 Jan 19, 2018
@paulmelnikow paulmelnikow deleted the base-badge-data-2 branch January 19, 2018 16:03
paulmelnikow added a commit that referenced this pull request Mar 12, 2018
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Server, BaseService, GitHub auth, Shared helpers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants