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

[DialogTitle] Test scenario where children are a string #6386

Merged

Conversation

agamrafaeli
Copy link
Contributor

  • PR has tests / docs demo, and is linted.
  • Commit and PR titles begin with [ComponentName], and are in imperative form: "[Component] Fix leaky abstraction".
  • Description explains the issue / use-case resolved, and auto-closes the related issue(s) (http://tr.im/vFqem).

@oliviertassinari
Copy link
Member

I'm gonna accept that PR as the work has already been done. But I don't think it's useful to test the string variation. Thanks.

@oliviertassinari oliviertassinari merged commit 1216598 into mui:next Mar 19, 2017
@muibot muibot added PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI and removed PR: Needs Review labels Mar 19, 2017
@agamrafaeli
Copy link
Contributor Author

Testing the string variation is important on a large scale project because you could get an exception there and never know it.

@oliviertassinari
Copy link
Member

@agamrafaeli Sure, but from my perspective, it feels like asserting 4 === 4 after asserting 3 === 3. That looks redundant. I might be wrong though.

@oliviertassinari oliviertassinari added PR: Review Accepted test and removed PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI labels Mar 21, 2017
@agamrafaeli agamrafaeli deleted the test-dialogtitle-string-children branch March 21, 2017 19:46
@mikew
Copy link
Contributor

mikew commented Apr 19, 2017

Not sure if it's from this PR, but there's different behaviour when using interpolated strings:

<DialogTitle>Edit The Thing</DialogTitle>

yields ...

screen shot 2017-04-19 at 7 13 54 pm

however ...

<DialogTitle>Edit The {'Thing'}</DialogTitle>

yields ...

screen shot 2017-04-19 at 7 14 14 pm

It might be necessary to check if children is an array of strings.

@oliviertassinari
Copy link
Member

@mikew No link with this PR. Still, that diff is coming from that logic:

      {typeof children === 'string' ? (
        <Text type="title">
          {children}
        </Text>
      ) : children}

I think that it would be better to change the switch logic by something more deterministic, like having a disableText property. Do you want to submit a PR?

@mikew
Copy link
Contributor

mikew commented Apr 22, 2017

Not sure what you mean, I was imagining

areAnyChildrenStrings = Array.isArray(children)
  ? children.filter(x => typeof x === 'string').length > 0
  : typeof x === 'string'

And then the statement you copied above, but branching off of areAnyChildrenStrings

@agamrafaeli
Copy link
Contributor Author

Thanks @oliviertassinari

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants