{"action":"created","comment":{"url":"https://api.github.com/repos/vuejs/vue-router/pulls/comments/77801540","id":77801540,"diff_hunk":"@@ -0,0 +1,54 @@\n+/*eslint-disable no-undef*/\n+import { createRouteMap } from '../../../src/create-route-map'\n+\n+const Home = { template: '<div>This is Home</div>' }\n+const Foo = { template: '<div>This is Foo</div>' }\n+const Bar = { template: '<div>This is Bar <router-view></router-view></div>' }\n+const Baz = { template: '<div>This is Baz</div>' }\n+\n+const routes = [\n+  { path: '/', name: 'home', component: Home },\n+  { path: '/foo', name: 'foo', component: Foo },\n+  {\n+    path: '/bar',\n+    name: 'bar',\n+    component: Bar,\n+    children: [\n+      {\n+        path: '',\n+        component: Baz,\n+        name: 'bar.baz'\n+      }\n+    ]\n+  }\n+]\n+\n+describe('Creating Route Map', function () {\n+  beforeAll(function () {\n+    spyOn(console, 'warn')\n+    this.maps = createRouteMap(routes)\n+  })\n+  beforeEach(function () {\n+    console.warn.calls.reset()\n+    process.env.NODE_ENV = 'production'\n+  })\n+\n+  it('has a pathMap object for default subroute at /bar/', function () {\n+    expect(this.maps.pathMap['/bar/']).not.toBeUndefined()\n+  })\n+\n+  it('has a nameMap object for default subroute at \\'bar.baz\\'', function () {\n+    expect(this.maps.nameMap['bar.baz']).not.toBeUndefined()\n+  })\n+\n+  it('in development, has logged a warning concering named route of parent and default subroute', function () {\n+    process.env.NODE_ENV = 'development'\n+    this.maps = createRouteMap(routes)\n+    expect(console.warn).toHaveBeenCalled()\n+    expect(console.warn.calls.argsFor(0)[0]).toMatch('vue-router] Named Route \\'bar\\'')","path":"test/unit/specs/create-map.spec.js","position":48,"original_position":48,"commit_id":"50b6f70dd575c32472d1e9a0c528da5958909273","original_commit_id":"50b6f70dd575c32472d1e9a0c528da5958909273","user":{"login":"LinusBorg","id":1444526,"avatar_url":"https://avatars.githubusercontent.com/u/1444526?v=3","gravatar_id":"","url":"https://api.github.com/users/LinusBorg","html_url":"https://github.com/LinusBorg","followers_url":"https://api.github.com/users/LinusBorg/followers","following_url":"https://api.github.com/users/LinusBorg/following{/other_user}","gists_url":"https://api.github.com/users/LinusBorg/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusBorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusBorg/subscriptions","organizations_url":"https://api.github.com/users/LinusBorg/orgs","repos_url":"https://api.github.com/users/LinusBorg/repos","events_url":"https://api.github.com/users/LinusBorg/events{/privacy}","received_events_url":"https://api.github.com/users/LinusBorg/received_events","type":"User","site_admin":false},"body":"`.toHaveBeenWarned()` is a custom jasmine test helper by Evan and I was not motivated to learn how to add it to vue-router as well, so I just used a jasmine spy on console.warn.\r\n\r\nThat spy is also the source of the `.calls` property that confused you ;)","created_at":"2016-09-07T11:05:03Z","updated_at":"2016-09-07T11:05:03Z","html_url":"https://github.com/vuejs/vue-router/pull/641#discussion_r77801540","pull_request_url":"https://api.github.com/repos/vuejs/vue-router/pulls/641","_links":{"self":{"href":"https://api.github.com/repos/vuejs/vue-router/pulls/comments/77801540"},"html":{"href":"https://github.com/vuejs/vue-router/pull/641#discussion_r77801540"},"pull_request":{"href":"https://api.github.com/repos/vuejs/vue-router/pulls/641"}}},"pull_request":{"url":"https://api.github.com/repos/vuejs/vue-router/pulls/641","id":83923416,"html_url":"https://github.com/vuejs/vue-router/pull/641","diff_url":"https://github.com/vuejs/vue-router/pull/641.diff","patch_url":"https://github.com/vuejs/vue-router/pull/641.patch","issue_url":"https://api.github.com/repos/vuejs/vue-router/issues/641","number":641,"state":"open","locked":false,"title":"Fix  #629 - add warning when named route has a default child route.","user":{"login":"LinusBorg","id":1444526,"avatar_url":"https://avatars.githubusercontent.com/u/1444526?v=3","gravatar_id":"","url":"https://api.github.com/users/LinusBorg","html_url":"https://github.com/LinusBorg","followers_url":"https://api.github.com/users/LinusBorg/followers","following_url":"https://api.github.com/users/LinusBorg/following{/other_user}","gists_url":"https://api.github.com/users/LinusBorg/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusBorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusBorg/subscriptions","organizations_url":"https://api.github.com/users/LinusBorg/orgs","repos_url":"https://api.github.com/users/LinusBorg/repos","events_url":"https://api.github.com/users/LinusBorg/events{/privacy}","received_events_url":"https://api.github.com/users/LinusBorg/received_events","type":"User","site_admin":false},"body":"### What does this PR do?\r\n\r\nThis change will log a warning to the console when the developer has defined a named route that also has a default child route.  The warning reads like this: \r\n\r\n> [vue-router] Named Route 'bar' has a default child route.\r\n> When navigating to this named route (:to=\"{name: 'bar'}\"), the default child route will not be rendered.\r\n> Remove the name from this route and use the name of the default child route for named links instead.\r\n\r\nIt will be logged to console once, during creation of the route map. I chose this to warn the user early and make him remove the name of the parent and instead only name the child.\r\n\r\nAlternatively, we could log this warning each time there's a transition to such a route, but I would prefer to trigger upfront.\r\n\r\n### Content of the Message\r\nI'm sure the warning message can be improved, just leave a suggestion here.\r\n\r\n### Tests\r\n\r\n* I tested the warning with a modified version of the \"named routes\" example. \r\n* I did not add a test case to the e2e tests, \r\n  * because I did not want to put a \"bad practice\" into the example, \r\n  * to put that into the examples I would have to mix nested and names routes, which are currently not mixed in their examples.\r\n* I did not add a unit test, because \r\n  * `create-route-map` has no unit tests so far.\r\n  * I'm struggling to get the \"hasBeenWarned()\" Test-helper form vue working here, which would be required to test weither the warning was logged.","created_at":"2016-09-04T13:52:11Z","updated_at":"2016-09-07T11:05:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"42c7cd6c38194a4dada8050ccd4731bdc669df6c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/vuejs/vue-router/pulls/641/commits","review_comments_url":"https://api.github.com/repos/vuejs/vue-router/pulls/641/comments","review_comment_url":"https://api.github.com/repos/vuejs/vue-router/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vuejs/vue-router/issues/641/comments","statuses_url":"https://api.github.com/repos/vuejs/vue-router/statuses/50b6f70dd575c32472d1e9a0c528da5958909273","head":{"label":"LinusBorg:warn_named_w_def_child","ref":"warn_named_w_def_child","sha":"50b6f70dd575c32472d1e9a0c528da5958909273","user":{"login":"LinusBorg","id":1444526,"avatar_url":"https://avatars.githubusercontent.com/u/1444526?v=3","gravatar_id":"","url":"https://api.github.com/users/LinusBorg","html_url":"https://github.com/LinusBorg","followers_url":"https://api.github.com/users/LinusBorg/followers","following_url":"https://api.github.com/users/LinusBorg/following{/other_user}","gists_url":"https://api.github.com/users/LinusBorg/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusBorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusBorg/subscriptions","organizations_url":"https://api.github.com/users/LinusBorg/orgs","repos_url":"https://api.github.com/users/LinusBorg/repos","events_url":"https://api.github.com/users/LinusBorg/events{/privacy}","received_events_url":"https://api.github.com/users/LinusBorg/received_events","type":"User","site_admin":false},"repo":{"id":60989276,"name":"vue-router","full_name":"LinusBorg/vue-router","owner":{"login":"LinusBorg","id":1444526,"avatar_url":"https://avatars.githubusercontent.com/u/1444526?v=3","gravatar_id":"","url":"https://api.github.com/users/LinusBorg","html_url":"https://github.com/LinusBorg","followers_url":"https://api.github.com/users/LinusBorg/followers","following_url":"https://api.github.com/users/LinusBorg/following{/other_user}","gists_url":"https://api.github.com/users/LinusBorg/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusBorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusBorg/subscriptions","organizations_url":"https://api.github.com/users/LinusBorg/orgs","repos_url":"https://api.github.com/users/LinusBorg/repos","events_url":"https://api.github.com/users/LinusBorg/events{/privacy}","received_events_url":"https://api.github.com/users/LinusBorg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/LinusBorg/vue-router","description":"The official router for Vue.js.","fork":true,"url":"https://api.github.com/repos/LinusBorg/vue-router","forks_url":"https://api.github.com/repos/LinusBorg/vue-router/forks","keys_url":"https://api.github.com/repos/LinusBorg/vue-router/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LinusBorg/vue-router/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LinusBorg/vue-router/teams","hooks_url":"https://api.github.com/repos/LinusBorg/vue-router/hooks","issue_events_url":"https://api.github.com/repos/LinusBorg/vue-router/issues/events{/number}","events_url":"https://api.github.com/repos/LinusBorg/vue-router/events","assignees_url":"https://api.github.com/repos/LinusBorg/vue-router/assignees{/user}","branches_url":"https://api.github.com/repos/LinusBorg/vue-router/branches{/branch}","tags_url":"https://api.github.com/repos/LinusBorg/vue-router/tags","blobs_url":"https://api.github.com/repos/LinusBorg/vue-router/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LinusBorg/vue-router/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LinusBorg/vue-router/git/refs{/sha}","trees_url":"https://api.github.com/repos/LinusBorg/vue-router/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LinusBorg/vue-router/statuses/{sha}","languages_url":"https://api.github.com/repos/LinusBorg/vue-router/languages","stargazers_url":"https://api.github.com/repos/LinusBorg/vue-router/stargazers","contributors_url":"https://api.github.com/repos/LinusBorg/vue-router/contributors","subscribers_url":"https://api.github.com/repos/LinusBorg/vue-router/subscribers","subscription_url":"https://api.github.com/repos/LinusBorg/vue-router/subscription","commits_url":"https://api.github.com/repos/LinusBorg/vue-router/commits{/sha}","git_commits_url":"https://api.github.com/repos/LinusBorg/vue-router/git/commits{/sha}","comments_url":"https://api.github.com/repos/LinusBorg/vue-router/comments{/number}","issue_comment_url":"https://api.github.com/repos/LinusBorg/vue-router/issues/comments{/number}","contents_url":"https://api.github.com/repos/LinusBorg/vue-router/contents/{+path}","compare_url":"https://api.github.com/repos/LinusBorg/vue-router/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LinusBorg/vue-router/merges","archive_url":"https://api.github.com/repos/LinusBorg/vue-router/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LinusBorg/vue-router/downloads","issues_url":"https://api.github.com/repos/LinusBorg/vue-router/issues{/number}","pulls_url":"https://api.github.com/repos/LinusBorg/vue-router/pulls{/number}","milestones_url":"https://api.github.com/repos/LinusBorg/vue-router/milestones{/number}","notifications_url":"https://api.github.com/repos/LinusBorg/vue-router/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LinusBorg/vue-router/labels{/name}","releases_url":"https://api.github.com/repos/LinusBorg/vue-router/releases{/id}","deployments_url":"https://api.github.com/repos/LinusBorg/vue-router/deployments","created_at":"2016-06-12T21:07:21Z","updated_at":"2016-06-12T21:07:22Z","pushed_at":"2016-09-06T16:58:02Z","git_url":"git://github.com/LinusBorg/vue-router.git","ssh_url":"git@github.com:LinusBorg/vue-router.git","clone_url":"https://github.com/LinusBorg/vue-router.git","svn_url":"https://github.com/LinusBorg/vue-router","homepage":"http://router.vuejs.org/","size":3841,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"vuejs:next","ref":"next","sha":"3c7f007280cdf4a1330159dc6c9c6c855d03f765","user":{"login":"vuejs","id":6128107,"avatar_url":"https://avatars.githubusercontent.com/u/6128107?v=3","gravatar_id":"","url":"https://api.github.com/users/vuejs","html_url":"https://github.com/vuejs","followers_url":"https://api.github.com/users/vuejs/followers","following_url":"https://api.github.com/users/vuejs/following{/other_user}","gists_url":"https://api.github.com/users/vuejs/gists{/gist_id}","starred_url":"https://api.github.com/users/vuejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vuejs/subscriptions","organizations_url":"https://api.github.com/users/vuejs/orgs","repos_url":"https://api.github.com/users/vuejs/repos","events_url":"https://api.github.com/users/vuejs/events{/privacy}","received_events_url":"https://api.github.com/users/vuejs/received_events","type":"Organization","site_admin":false},"repo":{"id":15116946,"name":"vue-router","full_name":"vuejs/vue-router","owner":{"login":"vuejs","id":6128107,"avatar_url":"https://avatars.githubusercontent.com/u/6128107?v=3","gravatar_id":"","url":"https://api.github.com/users/vuejs","html_url":"https://github.com/vuejs","followers_url":"https://api.github.com/users/vuejs/followers","following_url":"https://api.github.com/users/vuejs/following{/other_user}","gists_url":"https://api.github.com/users/vuejs/gists{/gist_id}","starred_url":"https://api.github.com/users/vuejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vuejs/subscriptions","organizations_url":"https://api.github.com/users/vuejs/orgs","repos_url":"https://api.github.com/users/vuejs/repos","events_url":"https://api.github.com/users/vuejs/events{/privacy}","received_events_url":"https://api.github.com/users/vuejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vuejs/vue-router","description":"The official router for Vue.js.","fork":false,"url":"https://api.github.com/repos/vuejs/vue-router","forks_url":"https://api.github.com/repos/vuejs/vue-router/forks","keys_url":"https://api.github.com/repos/vuejs/vue-router/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vuejs/vue-router/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vuejs/vue-router/teams","hooks_url":"https://api.github.com/repos/vuejs/vue-router/hooks","issue_events_url":"https://api.github.com/repos/vuejs/vue-router/issues/events{/number}","events_url":"https://api.github.com/repos/vuejs/vue-router/events","assignees_url":"https://api.github.com/repos/vuejs/vue-router/assignees{/user}","branches_url":"https://api.github.com/repos/vuejs/vue-router/branches{/branch}","tags_url":"https://api.github.com/repos/vuejs/vue-router/tags","blobs_url":"https://api.github.com/repos/vuejs/vue-router/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vuejs/vue-router/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vuejs/vue-router/git/refs{/sha}","trees_url":"https://api.github.com/repos/vuejs/vue-router/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vuejs/vue-router/statuses/{sha}","languages_url":"https://api.github.com/repos/vuejs/vue-router/languages","stargazers_url":"https://api.github.com/repos/vuejs/vue-router/stargazers","contributors_url":"https://api.github.com/repos/vuejs/vue-router/contributors","subscribers_url":"https://api.github.com/repos/vuejs/vue-router/subscribers","subscription_url":"https://api.github.com/repos/vuejs/vue-router/subscription","commits_url":"https://api.github.com/repos/vuejs/vue-router/commits{/sha}","git_commits_url":"https://api.github.com/repos/vuejs/vue-router/git/commits{/sha}","comments_url":"https://api.github.com/repos/vuejs/vue-router/comments{/number}","issue_comment_url":"https://api.github.com/repos/vuejs/vue-router/issues/comments{/number}","contents_url":"https://api.github.com/repos/vuejs/vue-router/contents/{+path}","compare_url":"https://api.github.com/repos/vuejs/vue-router/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vuejs/vue-router/merges","archive_url":"https://api.github.com/repos/vuejs/vue-router/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vuejs/vue-router/downloads","issues_url":"https://api.github.com/repos/vuejs/vue-router/issues{/number}","pulls_url":"https://api.github.com/repos/vuejs/vue-router/pulls{/number}","milestones_url":"https://api.github.com/repos/vuejs/vue-router/milestones{/number}","notifications_url":"https://api.github.com/repos/vuejs/vue-router/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vuejs/vue-router/labels{/name}","releases_url":"https://api.github.com/repos/vuejs/vue-router/releases{/id}","deployments_url":"https://api.github.com/repos/vuejs/vue-router/deployments","created_at":"2013-12-11T19:37:46Z","updated_at":"2016-09-07T08:54:32Z","pushed_at":"2016-09-06T19:28:12Z","git_url":"git://github.com/vuejs/vue-router.git","ssh_url":"git@github.com:vuejs/vue-router.git","clone_url":"https://github.com/vuejs/vue-router.git","svn_url":"https://github.com/vuejs/vue-router","homepage":"http://router.vuejs.org/","size":5620,"stargazers_count":2103,"watchers_count":2103,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":512,"mirror_url":null,"open_issues_count":52,"forks":512,"open_issues":52,"watchers":2103,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/vuejs/vue-router/pulls/641"},"html":{"href":"https://github.com/vuejs/vue-router/pull/641"},"issue":{"href":"https://api.github.com/repos/vuejs/vue-router/issues/641"},"comments":{"href":"https://api.github.com/repos/vuejs/vue-router/issues/641/comments"},"review_comments":{"href":"https://api.github.com/repos/vuejs/vue-router/pulls/641/comments"},"review_comment":{"href":"https://api.github.com/repos/vuejs/vue-router/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vuejs/vue-router/pulls/641/commits"},"statuses":{"href":"https://api.github.com/repos/vuejs/vue-router/statuses/50b6f70dd575c32472d1e9a0c528da5958909273"}}}}
{"actor":{"display_login":"LinusBorg"}}