{"action":"created","comment":{"url":"https://api.github.com/repos/spautz/parameterized-selectors/pulls/comments/211079303","pull_request_review_id":147434182,"id":211079303,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMTA3OTMwMw==","diff_hunk":"@@ -0,0 +1,297 @@\n+/* eslint-env mocha */\n+import chai from 'chai';\n+\n+import {\n+  COMPARISON_PRESETS,\n+  createParameterizedRootSelector,\n+  createParameterizedSelector,\n+} from '../src/index';\n+\n+const assert = chai.assert; // eslint-disable-line prefer-destructuring\n+\n+describe('Selectors for single objects', () => {\n+  const initialState = {\n+    authorDataById: {\n+      1: { name: 'Alice' },\n+      2: { name: 'Bob' },\n+      3: { name: 'Chris' },\n+    },\n+    bookDataById: {\n+      101: { title: 'Alphabet', authorId: 1 },\n+      102: { title: 'Binding', authorId: 2 },\n+      103: { title: 'Chapter', authorId: 1 },\n+      104: { title: 'Dewey Decimal', authorId: 2 },\n+    },\n+    bookIdsByAuthorId: {\n+      1: [101, 103],\n+      2: [102, 104],\n+      3: [],\n+    },\n+  };\n+\n+  let selectRawAuthorData;\n+  let selectRawBookData;\n+  let selectAuthor;\n+  let selectBook;\n+  let selectAuthorForBook;\n+\n+  beforeEach(() => {\n+    // The selectors get recreated for each test, to reset their call counts.\n+    // The root selector just returns the raw data in the state, while the selector that's built on top\n+    // of it will add in some additional fields.\n+    selectRawAuthorData = createParameterizedRootSelector(\n+      (state, authorId) => state.authorDataById[authorId],\n+      {\n+        displayName: 'selectRawAuthorData',\n+        compareSelectorResults: COMPARISON_PRESETS.SHALLOW_EQUAL,\n+        performanceChecksEnabled: true,\n+      },\n+    );\n+    selectRawBookData = createParameterizedRootSelector(\n+      (state, bookId) => state.bookDataById[bookId],\n+      {\n+        displayName: 'selectRawBookData',\n+        compareSelectorResults: COMPARISON_PRESETS.SHALLOW_EQUAL,\n+        performanceChecksEnabled: true,\n+      },\n+    );\n+\n+    // By convention in this test only, root selectors receive an ID directly while intermediate selectors\n+    // receive a params object.\n+    selectAuthor = createParameterizedSelector(\n+      ({ authorId }) => {\n+        const rawAuthorData = selectRawAuthorData(authorId);\n+        if (!rawAuthorData) {\n+          return null;\n+        }\n+        const name = (rawAuthorData.name || '').trim();\n+        return {\n+          ...rawAuthorData,\n+          authorId,\n+          name,\n+          nameLowerCase: name.toLowerCase(),\n+        };\n+      },\n+      {\n+        displayName: 'selectAuthor',\n+        compareSelectorResults: COMPARISON_PRESETS.SHALLOW_EQUAL,\n+        performanceChecksEnabled: true,\n+      },\n+    );\n+    selectBook = createParameterizedSelector(\n+      ({ bookId }) => {\n+        const rawBookData = selectRawBookData(bookId);\n+        if (!rawBookData) {\n+          return null;\n+        }\n+        const title = (rawBookData.title || '').trim();\n+        return {\n+          ...rawBookData,\n+          bookId,\n+          title,\n+          titleLowerCase: title.toLowerCase(),\n+        };\n+      },\n+      {\n+        displayName: 'selectBook',\n+        compareSelectorResults: COMPARISON_PRESETS.SHALLOW_EQUAL,\n+        performanceChecksEnabled: true,\n+      },\n+    );\n+\n+    selectAuthorForBook = createParameterizedSelector(\n+      (params) => {\n+        const book = selectBook(params);\n+        if (!book || !book.authorId) {\n+          return null;\n+        }\n+        return selectAuthor({ authorId: book.authorId });\n+      },\n+      {\n+        displayName: 'selectAuthorForBook',\n+        performanceChecksEnabled: true,\n+      },\n+    );\n+  });\n+\n+\n+  it('should return author models', () => {\n+    const firstAuthor = selectAuthor(initialState, { authorId: 1 });\n+    const secondAuthor = selectAuthor(initialState, { authorId: 2 });\n+\n+    assert.equal(firstAuthor.authorId, 1);\n+    assert.equal(firstAuthor, selectAuthor(initialState, { authorId: 1 }));","path":"tests/functional-scenarios.js","position":123,"original_position":123,"commit_id":"bca085738afa9e2de3868c2b59f8cfa611e21a0a","original_commit_id":"bca085738afa9e2de3868c2b59f8cfa611e21a0a","user":{"login":"spautz","id":243089,"node_id":"MDQ6VXNlcjI0MzA4OQ==","avatar_url":"https://avatars1.githubusercontent.com/u/243089?v=4","gravatar_id":"","url":"https://api.github.com/users/spautz","html_url":"https://github.com/spautz","followers_url":"https://api.github.com/users/spautz/followers","following_url":"https://api.github.com/users/spautz/following{/other_user}","gists_url":"https://api.github.com/users/spautz/gists{/gist_id}","starred_url":"https://api.github.com/users/spautz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spautz/subscriptions","organizations_url":"https://api.github.com/users/spautz/orgs","repos_url":"https://api.github.com/users/spautz/repos","events_url":"https://api.github.com/users/spautz/events{/privacy}","received_events_url":"https://api.github.com/users/spautz/received_events","type":"User","site_admin":false},"body":":+1: I'll work on this some more this weekend.","created_at":"2018-08-18T15:43:07Z","updated_at":"2018-08-18T15:43:08Z","html_url":"https://github.com/spautz/parameterized-selectors/pull/6#discussion_r211079303","pull_request_url":"https://api.github.com/repos/spautz/parameterized-selectors/pulls/6","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/spautz/parameterized-selectors/pulls/comments/211079303"},"html":{"href":"https://github.com/spautz/parameterized-selectors/pull/6#discussion_r211079303"},"pull_request":{"href":"https://api.github.com/repos/spautz/parameterized-selectors/pulls/6"}},"in_reply_to_id":210458615},"pull_request":{"url":"https://api.github.com/repos/spautz/parameterized-selectors/pulls/6","id":207860998,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3ODYwOTk4","html_url":"https://github.com/spautz/parameterized-selectors/pull/6","diff_url":"https://github.com/spautz/parameterized-selectors/pull/6.diff","patch_url":"https://github.com/spautz/parameterized-selectors/pull/6.patch","issue_url":"https://api.github.com/repos/spautz/parameterized-selectors/issues/6","number":6,"state":"open","locked":false,"title":"Counter & test updates","user":{"login":"spautz","id":243089,"node_id":"MDQ6VXNlcjI0MzA4OQ==","avatar_url":"https://avatars1.githubusercontent.com/u/243089?v=4","gravatar_id":"","url":"https://api.github.com/users/spautz","html_url":"https://github.com/spautz","followers_url":"https://api.github.com/users/spautz/followers","following_url":"https://api.github.com/users/spautz/following{/other_user}","gists_url":"https://api.github.com/users/spautz/gists{/gist_id}","starred_url":"https://api.github.com/users/spautz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spautz/subscriptions","organizations_url":"https://api.github.com/users/spautz/orgs","repos_url":"https://api.github.com/users/spautz/repos","events_url":"https://api.github.com/users/spautz/events{/privacy}","received_events_url":"https://api.github.com/users/spautz/received_events","type":"User","site_admin":false},"body":"This migrates the `recomputations` counter into the selector's closure, so that each one gets its own value, and adds a `callCount` for tracking the times we _could_ have run. Also added those two counters to be tracked by-paramKey (when performance logging is on) for better granularity.\r\n\r\nBegan adding a more end-to-end-ish integration test as well.","created_at":"2018-08-13T03:15:49Z","updated_at":"2018-08-18T15:43:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0ce1659951dd11236cdb5b1d7c9e45fe5ceab6f7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/spautz/parameterized-selectors/pulls/6/commits","review_comments_url":"https://api.github.com/repos/spautz/parameterized-selectors/pulls/6/comments","review_comment_url":"https://api.github.com/repos/spautz/parameterized-selectors/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spautz/parameterized-selectors/issues/6/comments","statuses_url":"https://api.github.com/repos/spautz/parameterized-selectors/statuses/bca085738afa9e2de3868c2b59f8cfa611e21a0a","head":{"label":"spautz:counter-updates","ref":"counter-updates","sha":"bca085738afa9e2de3868c2b59f8cfa611e21a0a","user":{"login":"spautz","id":243089,"node_id":"MDQ6VXNlcjI0MzA4OQ==","avatar_url":"https://avatars1.githubusercontent.com/u/243089?v=4","gravatar_id":"","url":"https://api.github.com/users/spautz","html_url":"https://github.com/spautz","followers_url":"https://api.github.com/users/spautz/followers","following_url":"https://api.github.com/users/spautz/following{/other_user}","gists_url":"https://api.github.com/users/spautz/gists{/gist_id}","starred_url":"https://api.github.com/users/spautz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spautz/subscriptions","organizations_url":"https://api.github.com/users/spautz/orgs","repos_url":"https://api.github.com/users/spautz/repos","events_url":"https://api.github.com/users/spautz/events{/privacy}","received_events_url":"https://api.github.com/users/spautz/received_events","type":"User","site_admin":false},"repo":{"id":141074009,"node_id":"MDEwOlJlcG9zaXRvcnkxNDEwNzQwMDk=","name":"parameterized-selectors","full_name":"spautz/parameterized-selectors","owner":{"login":"spautz","id":243089,"node_id":"MDQ6VXNlcjI0MzA4OQ==","avatar_url":"https://avatars1.githubusercontent.com/u/243089?v=4","gravatar_id":"","url":"https://api.github.com/users/spautz","html_url":"https://github.com/spautz","followers_url":"https://api.github.com/users/spautz/followers","following_url":"https://api.github.com/users/spautz/following{/other_user}","gists_url":"https://api.github.com/users/spautz/gists{/gist_id}","starred_url":"https://api.github.com/users/spautz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spautz/subscriptions","organizations_url":"https://api.github.com/users/spautz/orgs","repos_url":"https://api.github.com/users/spautz/repos","events_url":"https://api.github.com/users/spautz/events{/privacy}","received_events_url":"https://api.github.com/users/spautz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/spautz/parameterized-selectors","description":"A Reselect-inspired library where selectors can use params","fork":false,"url":"https://api.github.com/repos/spautz/parameterized-selectors","forks_url":"https://api.github.com/repos/spautz/parameterized-selectors/forks","keys_url":"https://api.github.com/repos/spautz/parameterized-selectors/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spautz/parameterized-selectors/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spautz/parameterized-selectors/teams","hooks_url":"https://api.github.com/repos/spautz/parameterized-selectors/hooks","issue_events_url":"https://api.github.com/repos/spautz/parameterized-selectors/issues/events{/number}","events_url":"https://api.github.com/repos/spautz/parameterized-selectors/events","assignees_url":"https://api.github.com/repos/spautz/parameterized-selectors/assignees{/user}","branches_url":"https://api.github.com/repos/spautz/parameterized-selectors/branches{/branch}","tags_url":"https://api.github.com/repos/spautz/parameterized-selectors/tags","blobs_url":"https://api.github.com/repos/spautz/parameterized-selectors/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spautz/parameterized-selectors/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spautz/parameterized-selectors/git/refs{/sha}","trees_url":"https://api.github.com/repos/spautz/parameterized-selectors/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spautz/parameterized-selectors/statuses/{sha}","languages_url":"https://api.github.com/repos/spautz/parameterized-selectors/languages","stargazers_url":"https://api.github.com/repos/spautz/parameterized-selectors/stargazers","contributors_url":"https://api.github.com/repos/spautz/parameterized-selectors/contributors","subscribers_url":"https://api.github.com/repos/spautz/parameterized-selectors/subscribers","subscription_url":"https://api.github.com/repos/spautz/parameterized-selectors/subscription","commits_url":"https://api.github.com/repos/spautz/parameterized-selectors/commits{/sha}","git_commits_url":"https://api.github.com/repos/spautz/parameterized-selectors/git/commits{/sha}","comments_url":"https://api.github.com/repos/spautz/parameterized-selectors/comments{/number}","issue_comment_url":"https://api.github.com/repos/spautz/parameterized-selectors/issues/comments{/number}","contents_url":"https://api.github.com/repos/spautz/parameterized-selectors/contents/{+path}","compare_url":"https://api.github.com/repos/spautz/parameterized-selectors/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spautz/parameterized-selectors/merges","archive_url":"https://api.github.com/repos/spautz/parameterized-selectors/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spautz/parameterized-selectors/downloads","issues_url":"https://api.github.com/repos/spautz/parameterized-selectors/issues{/number}","pulls_url":"https://api.github.com/repos/spautz/parameterized-selectors/pulls{/number}","milestones_url":"https://api.github.com/repos/spautz/parameterized-selectors/milestones{/number}","notifications_url":"https://api.github.com/repos/spautz/parameterized-selectors/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spautz/parameterized-selectors/labels{/name}","releases_url":"https://api.github.com/repos/spautz/parameterized-selectors/releases{/id}","deployments_url":"https://api.github.com/repos/spautz/parameterized-selectors/deployments","created_at":"2018-07-16T01:57:31Z","updated_at":"2018-08-13T12:59:54Z","pushed_at":"2018-08-13T03:15:49Z","git_url":"git://github.com/spautz/parameterized-selectors.git","ssh_url":"git@github.com:spautz/parameterized-selectors.git","clone_url":"https://github.com/spautz/parameterized-selectors.git","svn_url":"https://github.com/spautz/parameterized-selectors","homepage":null,"size":167,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":2,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"spautz:master","ref":"master","sha":"9e4f5c75d0ce8075eef8c054d07f695ab73169ac","user":{"login":"spautz","id":243089,"node_id":"MDQ6VXNlcjI0MzA4OQ==","avatar_url":"https://avatars1.githubusercontent.com/u/243089?v=4","gravatar_id":"","url":"https://api.github.com/users/spautz","html_url":"https://github.com/spautz","followers_url":"https://api.github.com/users/spautz/followers","following_url":"https://api.github.com/users/spautz/following{/other_user}","gists_url":"https://api.github.com/users/spautz/gists{/gist_id}","starred_url":"https://api.github.com/users/spautz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spautz/subscriptions","organizations_url":"https://api.github.com/users/spautz/orgs","repos_url":"https://api.github.com/users/spautz/repos","events_url":"https://api.github.com/users/spautz/events{/privacy}","received_events_url":"https://api.github.com/users/spautz/received_events","type":"User","site_admin":false},"repo":{"id":141074009,"node_id":"MDEwOlJlcG9zaXRvcnkxNDEwNzQwMDk=","name":"parameterized-selectors","full_name":"spautz/parameterized-selectors","owner":{"login":"spautz","id":243089,"node_id":"MDQ6VXNlcjI0MzA4OQ==","avatar_url":"https://avatars1.githubusercontent.com/u/243089?v=4","gravatar_id":"","url":"https://api.github.com/users/spautz","html_url":"https://github.com/spautz","followers_url":"https://api.github.com/users/spautz/followers","following_url":"https://api.github.com/users/spautz/following{/other_user}","gists_url":"https://api.github.com/users/spautz/gists{/gist_id}","starred_url":"https://api.github.com/users/spautz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spautz/subscriptions","organizations_url":"https://api.github.com/users/spautz/orgs","repos_url":"https://api.github.com/users/spautz/repos","events_url":"https://api.github.com/users/spautz/events{/privacy}","received_events_url":"https://api.github.com/users/spautz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/spautz/parameterized-selectors","description":"A Reselect-inspired library where selectors can use params","fork":false,"url":"https://api.github.com/repos/spautz/parameterized-selectors","forks_url":"https://api.github.com/repos/spautz/parameterized-selectors/forks","keys_url":"https://api.github.com/repos/spautz/parameterized-selectors/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spautz/parameterized-selectors/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spautz/parameterized-selectors/teams","hooks_url":"https://api.github.com/repos/spautz/parameterized-selectors/hooks","issue_events_url":"https://api.github.com/repos/spautz/parameterized-selectors/issues/events{/number}","events_url":"https://api.github.com/repos/spautz/parameterized-selectors/events","assignees_url":"https://api.github.com/repos/spautz/parameterized-selectors/assignees{/user}","branches_url":"https://api.github.com/repos/spautz/parameterized-selectors/branches{/branch}","tags_url":"https://api.github.com/repos/spautz/parameterized-selectors/tags","blobs_url":"https://api.github.com/repos/spautz/parameterized-selectors/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spautz/parameterized-selectors/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spautz/parameterized-selectors/git/refs{/sha}","trees_url":"https://api.github.com/repos/spautz/parameterized-selectors/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spautz/parameterized-selectors/statuses/{sha}","languages_url":"https://api.github.com/repos/spautz/parameterized-selectors/languages","stargazers_url":"https://api.github.com/repos/spautz/parameterized-selectors/stargazers","contributors_url":"https://api.github.com/repos/spautz/parameterized-selectors/contributors","subscribers_url":"https://api.github.com/repos/spautz/parameterized-selectors/subscribers","subscription_url":"https://api.github.com/repos/spautz/parameterized-selectors/subscription","commits_url":"https://api.github.com/repos/spautz/parameterized-selectors/commits{/sha}","git_commits_url":"https://api.github.com/repos/spautz/parameterized-selectors/git/commits{/sha}","comments_url":"https://api.github.com/repos/spautz/parameterized-selectors/comments{/number}","issue_comment_url":"https://api.github.com/repos/spautz/parameterized-selectors/issues/comments{/number}","contents_url":"https://api.github.com/repos/spautz/parameterized-selectors/contents/{+path}","compare_url":"https://api.github.com/repos/spautz/parameterized-selectors/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spautz/parameterized-selectors/merges","archive_url":"https://api.github.com/repos/spautz/parameterized-selectors/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spautz/parameterized-selectors/downloads","issues_url":"https://api.github.com/repos/spautz/parameterized-selectors/issues{/number}","pulls_url":"https://api.github.com/repos/spautz/parameterized-selectors/pulls{/number}","milestones_url":"https://api.github.com/repos/spautz/parameterized-selectors/milestones{/number}","notifications_url":"https://api.github.com/repos/spautz/parameterized-selectors/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spautz/parameterized-selectors/labels{/name}","releases_url":"https://api.github.com/repos/spautz/parameterized-selectors/releases{/id}","deployments_url":"https://api.github.com/repos/spautz/parameterized-selectors/deployments","created_at":"2018-07-16T01:57:31Z","updated_at":"2018-08-13T12:59:54Z","pushed_at":"2018-08-13T03:15:49Z","git_url":"git://github.com/spautz/parameterized-selectors.git","ssh_url":"git@github.com:spautz/parameterized-selectors.git","clone_url":"https://github.com/spautz/parameterized-selectors.git","svn_url":"https://github.com/spautz/parameterized-selectors","homepage":null,"size":167,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":2,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spautz/parameterized-selectors/pulls/6"},"html":{"href":"https://github.com/spautz/parameterized-selectors/pull/6"},"issue":{"href":"https://api.github.com/repos/spautz/parameterized-selectors/issues/6"},"comments":{"href":"https://api.github.com/repos/spautz/parameterized-selectors/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/spautz/parameterized-selectors/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/spautz/parameterized-selectors/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spautz/parameterized-selectors/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/spautz/parameterized-selectors/statuses/bca085738afa9e2de3868c2b59f8cfa611e21a0a"}},"author_association":"OWNER"}}
{"actor":{"display_login":"spautz"}}