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

Improve search results markup and add tests #62

Merged
merged 3 commits into from
Mar 3, 2016

Conversation

muffinresearch
Copy link
Contributor

  • Fixes some markup + use type="search" for the search.
  • Drys up some of the existing tests via beforeEach
  • Adds more conditional markup for the search results
  • Add tests for the search results

I'll file some issues for DRYing up the things we need in tests. Would be nice if we could have most of ReactTestUtils aliased in by default. Also I'll add and issues for adding l10n features.

@@ -7,24 +7,30 @@ const render = ReactTestUtils.renderIntoDocument;
const findByTag = ReactTestUtils.findRenderedDOMComponentWithTag;

describe('<SearchForm />', () => {
var onSearch;
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't really matter here but should we always prefer let?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could - I'm on the fence about that. I'm a bit too used to using var and I've only been using let when I need it. Maybe we should just use let and const and be done with it? Happy to hear thoughts on that - I can go with the consensus and adapt.

Copy link
Contributor

Choose a reason for hiding this comment

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

To me it seems like let is just var with less footguns. So we should always use let and const.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep fair enough - I'll move us to let + const. I might do it separate to this patch though since it'll be easier to review a patch that updates everything in one hit.

});

it('calls onSearch with a search query', () => {
const onSearch = sinon.spy();
const root = render(<SearchForm onSearch={onSearch} />);
root.refs.query.value = 'adblock';
Copy link
Contributor

Choose a reason for hiding this comment

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

This should use input.

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 ref value is query or are you suggesting changing it?

Copy link
Contributor

Choose a reason for hiding this comment

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

beforeEach has input = root.refs.query so this could be input.value instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I see. Yep I'll update it.

@mstriemer mstriemer mentioned this pull request Mar 3, 2016
it('renders error when query is an empty string', () => {
const root = renderResults({query: ''});
const searchResultsMsg = root.refs.message;
assert.include(searchResultsMsg.firstChild.nodeValue, 'supply a valid search');
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this use textContent like the others?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't need to since there's no active content so no implicit spans added by react.

@mstriemer
Copy link
Contributor

r+wc

muffinresearch added a commit that referenced this pull request Mar 3, 2016
Improve search results markup and add tests
@muffinresearch muffinresearch merged commit 1dcd1e7 into mozilla:master Mar 3, 2016
@muffinresearch muffinresearch deleted the fix-markup branch March 3, 2016 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants