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

Add [Coincap] Cryptocurrency badges #8623

Merged
merged 25 commits into from
Nov 18, 2022
Merged

Add [Coincap] Cryptocurrency badges #8623

merged 25 commits into from
Nov 18, 2022

Conversation

alexandresanlim
Copy link
Contributor

@alexandresanlim alexandresanlim commented Nov 12, 2022

Added

  • Symbol
  • Rank
  • Price
  • Change Percent on 24hr

@shields-ci
Copy link

shields-ci commented Nov 12, 2022

Messages
📖 ✨ Thanks for your contribution to Shields, @alexandresanlim!

Generated by 🚫 dangerJS against 8bd2c24

Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

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

This is in pretty good shape. It is clear you have read the contributing docs and thanks for including tests.


t.create('rank').get('/bitcoin.json').expectBadge({
label: 'Bitcoin',
message: '1',
Copy link
Member

@chris48s chris48s Nov 14, 2022

Choose a reason for hiding this comment

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

For the tests that call a live service, we sholdn't hard-code a response in the test. Lets validate that this as Joi.number().integer().min(1).required()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The .json return a string even being number, i had to validated it with regex.

Copy link
Member

Choose a reason for hiding this comment

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

You can still use Joi.number() to picture-check a string.

Try this as a minimal example:

import Joi from 'joi'

const schema = Joi.number().integer().min(1).required()

Joi.attempt('1', schema); // passes
Joi.attempt('0', schema); // fails

Same goes for the changepercent24hr and priceusd schemas - they can use Joi.number() instead of a regex which should make things a bit neater.

Copy link
Contributor Author

@alexandresanlim alexandresanlim Nov 16, 2022

Choose a reason for hiding this comment

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

Nice! but to changepercent24hr and priceusd Joi.number().required() doesn't worked.

const schema = Joi.object({
  data: Joi.object({
    changePercent24Hr: Joi.number().required(),
    name: Joi.string().required(),
  }).required(),
}).required()

@chris48s chris48s added the service-badge New or updated service badge label Nov 14, 2022
@alexandresanlim alexandresanlim marked this pull request as draft November 15, 2022 12:02
@alexandresanlim alexandresanlim marked this pull request as ready for review November 15, 2022 13:38

t.create('change percent 24hr').get('/bitcoin.json').expectBadge({
label: 'Bitcoin',
message: isPercentage,
Copy link
Member

Choose a reason for hiding this comment

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

Looking at the build for this branch it is failing with
ValidationError: message mismatch: "value" does not match any of the allowed types
because at the time the tests ran the change was negative and the validator isn't expecting a leading -.
We'll need to adjust the validator to allow negative values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added negative possibilities on test-validators.js ok?

@alexandresanlim alexandresanlim marked this pull request as draft November 16, 2022 21:18
@alexandresanlim alexandresanlim marked this pull request as ready for review November 16, 2022 23:09
Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

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

I spotted one more issue on the last check. The examples were rendering with label undefined. Merging with a fix for that

@chris48s chris48s merged commit a2751af into badges:master Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants