{"action":"created","comment":{"url":"https://api.github.com/repos/algolia/instantsearch.js/pulls/comments/43994250","id":43994250,"diff_hunk":"@@ -0,0 +1,85 @@\n+/* eslint-env mocha */\n+\n+import React from 'react';\n+import expect from 'expect';\n+import TestUtils from 'react-addons-test-utils';\n+import sinon from 'sinon';\n+import jsdom from 'mocha-jsdom';\n+\n+import expectJSX from 'expect-jsx';\n+expect.extend(expectJSX);\n+\n+import PriceRangesForm from '../PriceRangesForm';\n+\n+describe('PriceRangesForm', () => {\n+  var renderer;\n+\n+  jsdom({useEach: true});\n+\n+  beforeEach(() => {\n+    let {createRenderer} = TestUtils;\n+    renderer = createRenderer();\n+  });\n+\n+  function render(extraProps = {}) {\n+    var props = {\n+      ...extraProps\n+    };\n+    renderer.render(<PriceRangesForm {...props} />);\n+    return renderer.getRenderOutput();\n+  }\n+\n+  context('display', () => {\n+    it('should pass all css classes and labels', () => {\n+      let out = render({\n+        labels: {\n+          currency: '$',\n+          separator: 'to',\n+          button: 'Go'\n+        },\n+        cssClasses: {\n+          form: 'form',\n+          label: 'label',\n+          input: 'input',\n+          currency: 'currency',\n+          separator: 'separator',\n+          button: 'button'\n+        }\n+      });\n+      expect(out).toEqualJSX(\n+        <form className=\"form\" onSubmit={() => {}} ref=\"form\">\n+          <label className=\"label\">\n+            <span className=\"currency\">$ </span>\n+            <input className=\"input\" ref=\"from\" type=\"number\" />\n+          </label>\n+          <span className=\"separator\"> to </span>\n+          <label className=\"label\">\n+            <span className=\"currency\">$ </span>\n+            <input className=\"input\" ref=\"to\" type=\"number\" />\n+          </label>\n+          <button className=\"button\" type=\"submit\">Go</button>\n+        </form>\n+      );\n+    });\n+  });\n+\n+  context('submit', () => {\n+    it('starts a refine on submit', () => {\n+      // Given\n+      let refine = sinon.spy();\n+      let handleSubmitMock = sinon.spy(PriceRangesForm.prototype, 'handleSubmit');\n+      let component = TestUtils.renderIntoDocument(<PriceRangesForm refine={refine} />);\n+\n+      // When\n+      component.refs.from.value = 10;\n+      TestUtils.Simulate.change(component.refs.from);\n+      component.refs.to.value = 20;\n+      TestUtils.Simulate.change(component.refs.to);\n+      TestUtils.Simulate.submit(component.refs.form);\n+\n+      // Then\n+      expect(handleSubmitMock.calledOnce).toBe(true);\n+      expect(refine.calledWith(10, 20)).toBe(true);","path":"components/PriceRanges/__tests__/PriceRangesForm-test.js","position":82,"original_position":82,"commit_id":"ad58d7af20dcd9f7683b74b5edd4d42649c55188","original_commit_id":"ad58d7af20dcd9f7683b74b5edd4d42649c55188","user":{"login":"pixelastic","id":283419,"avatar_url":"https://avatars.githubusercontent.com/u/283419?v=3","gravatar_id":"","url":"https://api.github.com/users/pixelastic","html_url":"https://github.com/pixelastic","followers_url":"https://api.github.com/users/pixelastic/followers","following_url":"https://api.github.com/users/pixelastic/following{/other_user}","gists_url":"https://api.github.com/users/pixelastic/gists{/gist_id}","starred_url":"https://api.github.com/users/pixelastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixelastic/subscriptions","organizations_url":"https://api.github.com/users/pixelastic/orgs","repos_url":"https://api.github.com/users/pixelastic/repos","events_url":"https://api.github.com/users/pixelastic/events{/privacy}","received_events_url":"https://api.github.com/users/pixelastic/received_events","type":"User","site_admin":false},"body":"Yep, I now see what you mean. I was convinced I did two tests: one for checking that `handleSubmit` was called on `submit`, and another to test that `handleSubmit` correctly calls `refine`. I did not and tested everything in the same test, my bad","created_at":"2015-11-05T10:02:13Z","updated_at":"2015-11-05T10:02:13Z","html_url":"https://github.com/algolia/instantsearch.js/pull/390#discussion_r43994250","pull_request_url":"https://api.github.com/repos/algolia/instantsearch.js/pulls/390","_links":{"self":{"href":"https://api.github.com/repos/algolia/instantsearch.js/pulls/comments/43994250"},"html":{"href":"https://github.com/algolia/instantsearch.js/pull/390#discussion_r43994250"},"pull_request":{"href":"https://api.github.com/repos/algolia/instantsearch.js/pulls/390"}}},"pull_request":{"url":"https://api.github.com/repos/algolia/instantsearch.js/pulls/390","id":49253700,"html_url":"https://github.com/algolia/instantsearch.js/pull/390","diff_url":"https://github.com/algolia/instantsearch.js/pull/390.diff","patch_url":"https://github.com/algolia/instantsearch.js/pull/390.patch","issue_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/390","number":390,"state":"closed","locked":false,"title":"feat(priceRanges): Add BEM classes and tests","user":{"login":"pixelastic","id":283419,"avatar_url":"https://avatars.githubusercontent.com/u/283419?v=3","gravatar_id":"","url":"https://api.github.com/users/pixelastic","html_url":"https://github.com/pixelastic","followers_url":"https://api.github.com/users/pixelastic/followers","following_url":"https://api.github.com/users/pixelastic/following{/other_user}","gists_url":"https://api.github.com/users/pixelastic/gists{/gist_id}","starred_url":"https://api.github.com/users/pixelastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixelastic/subscriptions","organizations_url":"https://api.github.com/users/pixelastic/orgs","repos_url":"https://api.github.com/users/pixelastic/repos","events_url":"https://api.github.com/users/pixelastic/events{/privacy}","received_events_url":"https://api.github.com/users/pixelastic/received_events","type":"User","site_admin":false},"body":"Fixes #387\n\nBREAKING CHANGE: `ais-price-ranges--range` are now named\n`ais-price-ranges--item` and are wrapped in\na `ais-price-ranges--list`.\n\nI've moved the bottom form into it's own PriceRangesForm component,\nalong with its own tests. I've fixed a minor typo where the component\nwas internally named PriceRange (without the final __s__).\n\nI factorize some logic form the render in individual methods and\nmanage to individually test them. This was not an easy task. I had to\nmock the default `render` (so it does nothing) before instanciating\nthe component. Then, I was able to call each inner method\nindividually. This requires to stub prototype methods in beforeEach,\nthen restore them in afterEach. I've added a few helper methods, this\ncan surely be simplified again but this gives nice granularity in\ntesting.\n\nI've renamed the `range` items to `item` and wrapped them in a `list`.\nI've also added classes to all elements we add (`label`, `separator`,\netc). I've removed the empty `span`s.","created_at":"2015-10-30T10:38:19Z","updated_at":"2015-11-05T10:02:13Z","closed_at":"2015-11-02T10:55:16Z","merged_at":"2015-11-02T10:55:16Z","merge_commit_sha":"92dfb31f4cebda507769816b858d4d83ccc9700a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/algolia/instantsearch.js/pulls/390/commits","review_comments_url":"https://api.github.com/repos/algolia/instantsearch.js/pulls/390/comments","review_comment_url":"https://api.github.com/repos/algolia/instantsearch.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/390/comments","statuses_url":"https://api.github.com/repos/algolia/instantsearch.js/statuses/ad58d7af20dcd9f7683b74b5edd4d42649c55188","head":{"label":"algolia:fix/price-ranges-bem","ref":"fix/price-ranges-bem","sha":"ad58d7af20dcd9f7683b74b5edd4d42649c55188","user":{"login":"algolia","id":2034458,"avatar_url":"https://avatars.githubusercontent.com/u/2034458?v=3","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"repo":{"id":39443258,"name":"instantsearch.js","full_name":"algolia/instantsearch.js","owner":{"login":"algolia","id":2034458,"avatar_url":"https://avatars.githubusercontent.com/u/2034458?v=3","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/algolia/instantsearch.js","description":"instantsearch.js is a library of widgets to build high performance instant search experiences using Algolia","fork":false,"url":"https://api.github.com/repos/algolia/instantsearch.js","forks_url":"https://api.github.com/repos/algolia/instantsearch.js/forks","keys_url":"https://api.github.com/repos/algolia/instantsearch.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/algolia/instantsearch.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/algolia/instantsearch.js/teams","hooks_url":"https://api.github.com/repos/algolia/instantsearch.js/hooks","issue_events_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/events{/number}","events_url":"https://api.github.com/repos/algolia/instantsearch.js/events","assignees_url":"https://api.github.com/repos/algolia/instantsearch.js/assignees{/user}","branches_url":"https://api.github.com/repos/algolia/instantsearch.js/branches{/branch}","tags_url":"https://api.github.com/repos/algolia/instantsearch.js/tags","blobs_url":"https://api.github.com/repos/algolia/instantsearch.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/algolia/instantsearch.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/algolia/instantsearch.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/algolia/instantsearch.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/algolia/instantsearch.js/statuses/{sha}","languages_url":"https://api.github.com/repos/algolia/instantsearch.js/languages","stargazers_url":"https://api.github.com/repos/algolia/instantsearch.js/stargazers","contributors_url":"https://api.github.com/repos/algolia/instantsearch.js/contributors","subscribers_url":"https://api.github.com/repos/algolia/instantsearch.js/subscribers","subscription_url":"https://api.github.com/repos/algolia/instantsearch.js/subscription","commits_url":"https://api.github.com/repos/algolia/instantsearch.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/algolia/instantsearch.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/algolia/instantsearch.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/algolia/instantsearch.js/contents/{+path}","compare_url":"https://api.github.com/repos/algolia/instantsearch.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/algolia/instantsearch.js/merges","archive_url":"https://api.github.com/repos/algolia/instantsearch.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/algolia/instantsearch.js/downloads","issues_url":"https://api.github.com/repos/algolia/instantsearch.js/issues{/number}","pulls_url":"https://api.github.com/repos/algolia/instantsearch.js/pulls{/number}","milestones_url":"https://api.github.com/repos/algolia/instantsearch.js/milestones{/number}","notifications_url":"https://api.github.com/repos/algolia/instantsearch.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/algolia/instantsearch.js/labels{/name}","releases_url":"https://api.github.com/repos/algolia/instantsearch.js/releases{/id}","created_at":"2015-07-21T12:10:27Z","updated_at":"2015-11-05T09:50:13Z","pushed_at":"2015-11-05T09:50:31Z","git_url":"git://github.com/algolia/instantsearch.js.git","ssh_url":"git@github.com:algolia/instantsearch.js.git","clone_url":"https://github.com/algolia/instantsearch.js.git","svn_url":"https://github.com/algolia/instantsearch.js","homepage":"","size":6989,"stargazers_count":24,"watchers_count":24,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":58,"forks":2,"open_issues":58,"watchers":24,"default_branch":"master"}},"base":{"label":"algolia:develop","ref":"develop","sha":"09e8f7f94f0972c7ba0537fad93c8e78bbd87554","user":{"login":"algolia","id":2034458,"avatar_url":"https://avatars.githubusercontent.com/u/2034458?v=3","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"repo":{"id":39443258,"name":"instantsearch.js","full_name":"algolia/instantsearch.js","owner":{"login":"algolia","id":2034458,"avatar_url":"https://avatars.githubusercontent.com/u/2034458?v=3","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/algolia/instantsearch.js","description":"instantsearch.js is a library of widgets to build high performance instant search experiences using Algolia","fork":false,"url":"https://api.github.com/repos/algolia/instantsearch.js","forks_url":"https://api.github.com/repos/algolia/instantsearch.js/forks","keys_url":"https://api.github.com/repos/algolia/instantsearch.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/algolia/instantsearch.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/algolia/instantsearch.js/teams","hooks_url":"https://api.github.com/repos/algolia/instantsearch.js/hooks","issue_events_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/events{/number}","events_url":"https://api.github.com/repos/algolia/instantsearch.js/events","assignees_url":"https://api.github.com/repos/algolia/instantsearch.js/assignees{/user}","branches_url":"https://api.github.com/repos/algolia/instantsearch.js/branches{/branch}","tags_url":"https://api.github.com/repos/algolia/instantsearch.js/tags","blobs_url":"https://api.github.com/repos/algolia/instantsearch.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/algolia/instantsearch.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/algolia/instantsearch.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/algolia/instantsearch.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/algolia/instantsearch.js/statuses/{sha}","languages_url":"https://api.github.com/repos/algolia/instantsearch.js/languages","stargazers_url":"https://api.github.com/repos/algolia/instantsearch.js/stargazers","contributors_url":"https://api.github.com/repos/algolia/instantsearch.js/contributors","subscribers_url":"https://api.github.com/repos/algolia/instantsearch.js/subscribers","subscription_url":"https://api.github.com/repos/algolia/instantsearch.js/subscription","commits_url":"https://api.github.com/repos/algolia/instantsearch.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/algolia/instantsearch.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/algolia/instantsearch.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/algolia/instantsearch.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/algolia/instantsearch.js/contents/{+path}","compare_url":"https://api.github.com/repos/algolia/instantsearch.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/algolia/instantsearch.js/merges","archive_url":"https://api.github.com/repos/algolia/instantsearch.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/algolia/instantsearch.js/downloads","issues_url":"https://api.github.com/repos/algolia/instantsearch.js/issues{/number}","pulls_url":"https://api.github.com/repos/algolia/instantsearch.js/pulls{/number}","milestones_url":"https://api.github.com/repos/algolia/instantsearch.js/milestones{/number}","notifications_url":"https://api.github.com/repos/algolia/instantsearch.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/algolia/instantsearch.js/labels{/name}","releases_url":"https://api.github.com/repos/algolia/instantsearch.js/releases{/id}","created_at":"2015-07-21T12:10:27Z","updated_at":"2015-11-05T09:50:13Z","pushed_at":"2015-11-05T09:50:31Z","git_url":"git://github.com/algolia/instantsearch.js.git","ssh_url":"git@github.com:algolia/instantsearch.js.git","clone_url":"https://github.com/algolia/instantsearch.js.git","svn_url":"https://github.com/algolia/instantsearch.js","homepage":"","size":6989,"stargazers_count":24,"watchers_count":24,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":58,"forks":2,"open_issues":58,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/algolia/instantsearch.js/pulls/390"},"html":{"href":"https://github.com/algolia/instantsearch.js/pull/390"},"issue":{"href":"https://api.github.com/repos/algolia/instantsearch.js/issues/390"},"comments":{"href":"https://api.github.com/repos/algolia/instantsearch.js/issues/390/comments"},"review_comments":{"href":"https://api.github.com/repos/algolia/instantsearch.js/pulls/390/comments"},"review_comment":{"href":"https://api.github.com/repos/algolia/instantsearch.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/algolia/instantsearch.js/pulls/390/commits"},"statuses":{"href":"https://api.github.com/repos/algolia/instantsearch.js/statuses/ad58d7af20dcd9f7683b74b5edd4d42649c55188"}}}}