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

[jest-each] Fix each array title concatenation #6346

Merged
merged 4 commits into from
May 30, 2018

Conversation

mattphillips
Copy link
Contributor

Summary

Fixes #6342

Test plan

  • Add test to check all placeholder types work
  • Add test to verify args aren't concatenated by default by util.format

@codecov-io
Copy link

Codecov Report

Merging #6346 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6346      +/-   ##
==========================================
+ Coverage   63.63%   63.65%   +0.02%     
==========================================
  Files         226      226              
  Lines        8648     8654       +6     
  Branches        4        4              
==========================================
+ Hits         5503     5509       +6     
  Misses       3144     3144              
  Partials        1        1
Impacted Files Coverage Δ
packages/jest-each/src/bind.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2307643...dd3f9fc. Read the comment docs.

Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

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

LGTM

const arrayFormat = (str, ...args) => {
const matches = (str.match(SUPPORTED_PLACEHOLDERS) || []).length;
return util.format(str, ...args.slice(0, matches));
};
Copy link
Member

@SimenB SimenB May 30, 2018

Choose a reason for hiding this comment

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

what about matches.length > args.length?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.slice is greedy and will take all of the args still, there will just be some placeholders that aren't replaced. Do we care about this case? I think it should be pretty obvious that the placeholders aren't replaced as there isn't a value for them 😆

Copy link
Member

Choose a reason for hiding this comment

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

Should we throw? Probably not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if it should fail the tests, I wouldn't say its an error case. Just a developer mistake, perhaps we could log a warning?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can add a lint rule for it?

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 like it 😄

@cpojer
Copy link
Member

cpojer commented May 30, 2018

Please rebase.

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test.each: Allow test name to not include every test arg
6 participants