{"action":"created","comment":{"url":"https://api.github.com/repos/mendixlabs/google-maps/pulls/comments/90889142","pull_request_review_id":11378933,"id":90889142,"diff_hunk":"@@ -0,0 +1,201 @@\n+import { shallow } from \"enzyme\";\n+import GoogleMap from \"google-map-react\";\n+import { DOM, createElement } from \"react\";\n+\n+import { Map, MapProps } from \"../Map\";\n+import { Marker } from \"../Marker\";\n+\n+import {\n+    EventMock, GeocoderLocationType, GeocoderMock, GeocoderStatus, LatLngBoundsMock,\n+    LatLngMock, MapsMock, MarkerMock, MockGoogle\n+} from \"../../../../../../../tests/mocks/GoogleMaps\";\n+\n+import { MxMock, MxUiMock } from \"../../../../../../../tests/mocks/Mendix\";\n+describe(\"Map\", () => {\n+    const address = \"Lumumba Ave, Kampala, Uganda\";\n+    const invalidAddress = \"invalidAddress\";\n+    const APIKey = \"AIzaSyACjBNesZXeRFx86N7RMCWiTQP5GT_jDec\";\n+    const renderMap = (props: MapProps) => shallow(createElement(Map, props));\n+    const defaultCenterLocation = { lat: 51.9107963, lng: 4.4789878 };\n+    const successMockLocation = { lat: 30, lng: 118 };\n+    const multipleAddressMockLocation = { lat: 34.213171, lng: -118.571022 };\n+\n+    beforeAll(() => {\n+        window.google = MockGoogle;\n+        window.google.maps = {};\n+        window.google.maps.Geocoder = GeocoderMock;\n+        window.google.maps.Map = MapsMock;\n+        window.google.maps.LatLngBounds = LatLngBoundsMock;\n+        window.google.maps.LatLng = LatLngMock;\n+        window.google.maps.Marker = MarkerMock;\n+        window.google.maps.event = EventMock;\n+        window.google.maps.GeocoderStatus = GeocoderStatus;\n+        window.google.maps.GeocoderLocationType = GeocoderLocationType;\n+        window.mx = MxMock.prototype;\n+        window.mx.ui = MxUiMock.prototype;\n+    });\n+\n+    it(\"should render with the map structure\", () => {\n+        const map = renderMap({ address });\n+        expect(map).toBeElement(\n+            DOM.div({ className: \"widget-google-maps\" },\n+                createElement(GoogleMap, {\n+                    bootstrapURLKeys: { key: undefined },\n+                    center: defaultCenterLocation,\n+                    defaultZoom: 14,\n+                    onGoogleApiLoaded: jasmine.any(Function) as any,\n+                    resetBoundsOnResize: true,\n+                    yesIWantToUseGoogleMapApiInternals: true\n+                })\n+            )\n+        );\n+    });\n+\n+    it(\"renders with classes\", () => {\n+        const googleMap = renderMap({ address });\n+\n+        expect(googleMap.hasClass(\"widget-google-maps\")).toBe(true);\n+    });\n+\n+    describe(\"with no address\", () => {\n+        it(\"should not look up the location\", () => {\n+            spyOn(window.google.maps.Geocoder.prototype, \"geocode\").and.callThrough();\n+\n+            const output = renderMap({ address: \"\" });\n+            output.find(GoogleMap).prop(\"onGoogleApiLoaded\")();\n+\n+            expect(window.google.maps.Geocoder.prototype.geocode).not.toHaveBeenCalled();\n+        });\n+\n+        it(\"should not display a marker\", () => {\n+            const output = renderMap({ address: \"\" });\n+            output.find(GoogleMap).prop(\"onGoogleApiLoaded\")();\n+\n+            const marker = output.find(Marker);\n+            expect(marker.length).toBe(0);\n+        });\n+\n+        it(\"should center to the default address\", () => {\n+            const googleMap = renderMap({ address }).childAt(0);\n+\n+            expect(googleMap.prop(\"center\").lat).toBe(defaultCenterLocation.lat);\n+            expect(googleMap.prop(\"center\").lng).toBe(defaultCenterLocation.lng);\n+        });\n+    });\n+\n+    describe(\"with a valid address\", () => {\n+        it(\"should lookup the location\", () => {\n+            spyOn(window.google.maps.Geocoder.prototype, \"geocode\");\n+\n+            const output = renderMap({ address });\n+            output.find(GoogleMap).prop(\"onGoogleApiLoaded\")();\n+\n+            expect(window.google.maps.Geocoder.prototype.geocode).toHaveBeenCalled();\n+        });\n+\n+        it(\"should render a marker\", () => {\n+            const output = renderMap({ address });\n+            output.find(GoogleMap).prop(\"onGoogleApiLoaded\")();\n+\n+            const marker = output.find(Marker);\n+            expect(marker.length).toBe(1);\n+            expect(marker.prop(\"lat\")).toBe(successMockLocation.lat);\n+            expect(marker.prop(\"lng\")).toBe(successMockLocation.lng);\n+        });\n+\n+        it(\"should center to the location of the address\", () => {\n+            const output = renderMap({ address });\n+            const mapComponent = output.instance() as Map;\n+            output.find(GoogleMap).prop(\"onGoogleApiLoaded\")();\n+\n+            expect(mapComponent.state.location.lat).toBe(successMockLocation.lat);\n+            expect(mapComponent.state.location.lng).toBe(successMockLocation.lng);\n+        });\n+\n+        it(\"should display the first marker if multiple locations are found\", () => {\n+            const output = renderMap({ address: \"multipleAddress\" });\n+            output.find(GoogleMap).prop(\"onGoogleApiLoaded\")();\n+\n+            const marker = output.find(Marker);\n+            expect(marker.prop(\"lat\")).toBe(multipleAddressMockLocation.lat);\n+            expect(marker.prop(\"lng\")).toBe(multipleAddressMockLocation.lng);\n+        });\n+    });\n+\n+    describe(\"with an invalid address\", () => {\n+        it(\"should not render a marker\", () => {\n+            const output = renderMap({ address: invalidAddress });\n+            output.find(GoogleMap).prop(\"onGoogleApiLoaded\")();\n+\n+            const marker = output.find(Marker);\n+            expect(marker.length).toBe(0);\n+        });\n+\n+        it(\"should center to the default address\", () => {\n+            const output = renderMap({ address: invalidAddress });\n+            output.find(GoogleMap).prop(\"onGoogleApiLoaded\")();\n+\n+            const marker = output.childAt(0);\n+            expect(marker.prop(\"center\").lat).toBe(defaultCenterLocation.lat);\n+            expect(marker.prop(\"center\").lng).toBe(defaultCenterLocation.lng);\n+        });\n+\n+        it(\"should display an error\", () => {\n+            spyOn(window.mx.ui, \"error\").and.callThrough();\n+\n+            const output = renderMap({ address: invalidAddress });\n+            output.find(GoogleMap).prop(\"onGoogleApiLoaded\")();\n+\n+            expect(window.mx.ui.error).toHaveBeenCalled();\n+        });\n+    });\n+\n+    describe(\"on loading\", () => {\n+        it(\"should load the google maps script without API key\", () => {","path":"src/com/mendix/widget/GoogleMaps/components/__tests__/Map.spec.ts","position":154,"original_position":154,"commit_id":"67fef2c11d91d125414e19fcc0bcd9c4a8c7ddff","original_commit_id":"67fef2c11d91d125414e19fcc0bcd9c4a8c7ddff","user":{"login":"mijay","id":697828,"avatar_url":"https://avatars.githubusercontent.com/u/697828?v=3","gravatar_id":"","url":"https://api.github.com/users/mijay","html_url":"https://github.com/mijay","followers_url":"https://api.github.com/users/mijay/followers","following_url":"https://api.github.com/users/mijay/following{/other_user}","gists_url":"https://api.github.com/users/mijay/gists{/gist_id}","starred_url":"https://api.github.com/users/mijay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mijay/subscriptions","organizations_url":"https://api.github.com/users/mijay/orgs","repos_url":"https://api.github.com/users/mijay/repos","events_url":"https://api.github.com/users/mijay/events{/privacy}","received_events_url":"https://api.github.com/users/mijay/received_events","type":"User","site_admin":false},"body":"... if no key is configured","created_at":"2016-12-05T15:38:52Z","updated_at":"2016-12-05T15:39:17Z","html_url":"https://github.com/mendixlabs/google-maps/pull/2#discussion_r90889142","pull_request_url":"https://api.github.com/repos/mendixlabs/google-maps/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/mendixlabs/google-maps/pulls/comments/90889142"},"html":{"href":"https://github.com/mendixlabs/google-maps/pull/2#discussion_r90889142"},"pull_request":{"href":"https://api.github.com/repos/mendixlabs/google-maps/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/mendixlabs/google-maps/pulls/2","id":96068638,"html_url":"https://github.com/mendixlabs/google-maps/pull/2","diff_url":"https://github.com/mendixlabs/google-maps/pull/2.diff","patch_url":"https://github.com/mendixlabs/google-maps/pull/2.patch","issue_url":"https://api.github.com/repos/mendixlabs/google-maps/issues/2","number":2,"state":"open","locked":false,"title":"Show address on Google Maps","user":{"login":"Andries-Smit","id":6724749,"avatar_url":"https://avatars.githubusercontent.com/u/6724749?v=3","gravatar_id":"","url":"https://api.github.com/users/Andries-Smit","html_url":"https://github.com/Andries-Smit","followers_url":"https://api.github.com/users/Andries-Smit/followers","following_url":"https://api.github.com/users/Andries-Smit/following{/other_user}","gists_url":"https://api.github.com/users/Andries-Smit/gists{/gist_id}","starred_url":"https://api.github.com/users/Andries-Smit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andries-Smit/subscriptions","organizations_url":"https://api.github.com/users/Andries-Smit/orgs","repos_url":"https://api.github.com/users/Andries-Smit/repos","events_url":"https://api.github.com/users/Andries-Smit/events{/privacy}","received_events_url":"https://api.github.com/users/Andries-Smit/received_events","type":"User","site_admin":false},"body":"Show location on a map based on an address","created_at":"2016-12-01T11:10:58Z","updated_at":"2016-12-05T15:41:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ea229c2f7b463366d1f58c82c3b8c5a1102951d1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mendixlabs/google-maps/pulls/2/commits","review_comments_url":"https://api.github.com/repos/mendixlabs/google-maps/pulls/2/comments","review_comment_url":"https://api.github.com/repos/mendixlabs/google-maps/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mendixlabs/google-maps/issues/2/comments","statuses_url":"https://api.github.com/repos/mendixlabs/google-maps/statuses/67fef2c11d91d125414e19fcc0bcd9c4a8c7ddff","head":{"label":"FlockOfBirds:google-map-react","ref":"google-map-react","sha":"67fef2c11d91d125414e19fcc0bcd9c4a8c7ddff","user":{"login":"FlockOfBirds","id":22542218,"avatar_url":"https://avatars.githubusercontent.com/u/22542218?v=3","gravatar_id":"","url":"https://api.github.com/users/FlockOfBirds","html_url":"https://github.com/FlockOfBirds","followers_url":"https://api.github.com/users/FlockOfBirds/followers","following_url":"https://api.github.com/users/FlockOfBirds/following{/other_user}","gists_url":"https://api.github.com/users/FlockOfBirds/gists{/gist_id}","starred_url":"https://api.github.com/users/FlockOfBirds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FlockOfBirds/subscriptions","organizations_url":"https://api.github.com/users/FlockOfBirds/orgs","repos_url":"https://api.github.com/users/FlockOfBirds/repos","events_url":"https://api.github.com/users/FlockOfBirds/events{/privacy}","received_events_url":"https://api.github.com/users/FlockOfBirds/received_events","type":"Organization","site_admin":false},"repo":{"id":70687494,"name":"google-maps","full_name":"FlockOfBirds/google-maps","owner":{"login":"FlockOfBirds","id":22542218,"avatar_url":"https://avatars.githubusercontent.com/u/22542218?v=3","gravatar_id":"","url":"https://api.github.com/users/FlockOfBirds","html_url":"https://github.com/FlockOfBirds","followers_url":"https://api.github.com/users/FlockOfBirds/followers","following_url":"https://api.github.com/users/FlockOfBirds/following{/other_user}","gists_url":"https://api.github.com/users/FlockOfBirds/gists{/gist_id}","starred_url":"https://api.github.com/users/FlockOfBirds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FlockOfBirds/subscriptions","organizations_url":"https://api.github.com/users/FlockOfBirds/orgs","repos_url":"https://api.github.com/users/FlockOfBirds/repos","events_url":"https://api.github.com/users/FlockOfBirds/events{/privacy}","received_events_url":"https://api.github.com/users/FlockOfBirds/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FlockOfBirds/google-maps","description":"Google maps widget. No guarantees are given that this works or keeps working.","fork":true,"url":"https://api.github.com/repos/FlockOfBirds/google-maps","forks_url":"https://api.github.com/repos/FlockOfBirds/google-maps/forks","keys_url":"https://api.github.com/repos/FlockOfBirds/google-maps/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FlockOfBirds/google-maps/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FlockOfBirds/google-maps/teams","hooks_url":"https://api.github.com/repos/FlockOfBirds/google-maps/hooks","issue_events_url":"https://api.github.com/repos/FlockOfBirds/google-maps/issues/events{/number}","events_url":"https://api.github.com/repos/FlockOfBirds/google-maps/events","assignees_url":"https://api.github.com/repos/FlockOfBirds/google-maps/assignees{/user}","branches_url":"https://api.github.com/repos/FlockOfBirds/google-maps/branches{/branch}","tags_url":"https://api.github.com/repos/FlockOfBirds/google-maps/tags","blobs_url":"https://api.github.com/repos/FlockOfBirds/google-maps/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FlockOfBirds/google-maps/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FlockOfBirds/google-maps/git/refs{/sha}","trees_url":"https://api.github.com/repos/FlockOfBirds/google-maps/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FlockOfBirds/google-maps/statuses/{sha}","languages_url":"https://api.github.com/repos/FlockOfBirds/google-maps/languages","stargazers_url":"https://api.github.com/repos/FlockOfBirds/google-maps/stargazers","contributors_url":"https://api.github.com/repos/FlockOfBirds/google-maps/contributors","subscribers_url":"https://api.github.com/repos/FlockOfBirds/google-maps/subscribers","subscription_url":"https://api.github.com/repos/FlockOfBirds/google-maps/subscription","commits_url":"https://api.github.com/repos/FlockOfBirds/google-maps/commits{/sha}","git_commits_url":"https://api.github.com/repos/FlockOfBirds/google-maps/git/commits{/sha}","comments_url":"https://api.github.com/repos/FlockOfBirds/google-maps/comments{/number}","issue_comment_url":"https://api.github.com/repos/FlockOfBirds/google-maps/issues/comments{/number}","contents_url":"https://api.github.com/repos/FlockOfBirds/google-maps/contents/{+path}","compare_url":"https://api.github.com/repos/FlockOfBirds/google-maps/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FlockOfBirds/google-maps/merges","archive_url":"https://api.github.com/repos/FlockOfBirds/google-maps/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FlockOfBirds/google-maps/downloads","issues_url":"https://api.github.com/repos/FlockOfBirds/google-maps/issues{/number}","pulls_url":"https://api.github.com/repos/FlockOfBirds/google-maps/pulls{/number}","milestones_url":"https://api.github.com/repos/FlockOfBirds/google-maps/milestones{/number}","notifications_url":"https://api.github.com/repos/FlockOfBirds/google-maps/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FlockOfBirds/google-maps/labels{/name}","releases_url":"https://api.github.com/repos/FlockOfBirds/google-maps/releases{/id}","deployments_url":"https://api.github.com/repos/FlockOfBirds/google-maps/deployments","created_at":"2016-10-12T10:04:59Z","updated_at":"2016-11-02T07:09:41Z","pushed_at":"2016-12-01T11:08:26Z","git_url":"git://github.com/FlockOfBirds/google-maps.git","ssh_url":"git@github.com:FlockOfBirds/google-maps.git","clone_url":"https://github.com/FlockOfBirds/google-maps.git","svn_url":"https://github.com/FlockOfBirds/google-maps","homepage":null,"size":180,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mendixlabs:master","ref":"master","sha":"e277dfbbe339a581203fb9d751e60c9c60ce9d2f","user":{"login":"mendixlabs","id":22540445,"avatar_url":"https://avatars.githubusercontent.com/u/22540445?v=3","gravatar_id":"","url":"https://api.github.com/users/mendixlabs","html_url":"https://github.com/mendixlabs","followers_url":"https://api.github.com/users/mendixlabs/followers","following_url":"https://api.github.com/users/mendixlabs/following{/other_user}","gists_url":"https://api.github.com/users/mendixlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/mendixlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mendixlabs/subscriptions","organizations_url":"https://api.github.com/users/mendixlabs/orgs","repos_url":"https://api.github.com/users/mendixlabs/repos","events_url":"https://api.github.com/users/mendixlabs/events{/privacy}","received_events_url":"https://api.github.com/users/mendixlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":70053943,"name":"google-maps","full_name":"mendixlabs/google-maps","owner":{"login":"mendixlabs","id":22540445,"avatar_url":"https://avatars.githubusercontent.com/u/22540445?v=3","gravatar_id":"","url":"https://api.github.com/users/mendixlabs","html_url":"https://github.com/mendixlabs","followers_url":"https://api.github.com/users/mendixlabs/followers","following_url":"https://api.github.com/users/mendixlabs/following{/other_user}","gists_url":"https://api.github.com/users/mendixlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/mendixlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mendixlabs/subscriptions","organizations_url":"https://api.github.com/users/mendixlabs/orgs","repos_url":"https://api.github.com/users/mendixlabs/repos","events_url":"https://api.github.com/users/mendixlabs/events{/privacy}","received_events_url":"https://api.github.com/users/mendixlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mendixlabs/google-maps","description":"Google maps widget. No guarantees are given that this works or keeps working.","fork":false,"url":"https://api.github.com/repos/mendixlabs/google-maps","forks_url":"https://api.github.com/repos/mendixlabs/google-maps/forks","keys_url":"https://api.github.com/repos/mendixlabs/google-maps/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mendixlabs/google-maps/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mendixlabs/google-maps/teams","hooks_url":"https://api.github.com/repos/mendixlabs/google-maps/hooks","issue_events_url":"https://api.github.com/repos/mendixlabs/google-maps/issues/events{/number}","events_url":"https://api.github.com/repos/mendixlabs/google-maps/events","assignees_url":"https://api.github.com/repos/mendixlabs/google-maps/assignees{/user}","branches_url":"https://api.github.com/repos/mendixlabs/google-maps/branches{/branch}","tags_url":"https://api.github.com/repos/mendixlabs/google-maps/tags","blobs_url":"https://api.github.com/repos/mendixlabs/google-maps/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mendixlabs/google-maps/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mendixlabs/google-maps/git/refs{/sha}","trees_url":"https://api.github.com/repos/mendixlabs/google-maps/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mendixlabs/google-maps/statuses/{sha}","languages_url":"https://api.github.com/repos/mendixlabs/google-maps/languages","stargazers_url":"https://api.github.com/repos/mendixlabs/google-maps/stargazers","contributors_url":"https://api.github.com/repos/mendixlabs/google-maps/contributors","subscribers_url":"https://api.github.com/repos/mendixlabs/google-maps/subscribers","subscription_url":"https://api.github.com/repos/mendixlabs/google-maps/subscription","commits_url":"https://api.github.com/repos/mendixlabs/google-maps/commits{/sha}","git_commits_url":"https://api.github.com/repos/mendixlabs/google-maps/git/commits{/sha}","comments_url":"https://api.github.com/repos/mendixlabs/google-maps/comments{/number}","issue_comment_url":"https://api.github.com/repos/mendixlabs/google-maps/issues/comments{/number}","contents_url":"https://api.github.com/repos/mendixlabs/google-maps/contents/{+path}","compare_url":"https://api.github.com/repos/mendixlabs/google-maps/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mendixlabs/google-maps/merges","archive_url":"https://api.github.com/repos/mendixlabs/google-maps/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mendixlabs/google-maps/downloads","issues_url":"https://api.github.com/repos/mendixlabs/google-maps/issues{/number}","pulls_url":"https://api.github.com/repos/mendixlabs/google-maps/pulls{/number}","milestones_url":"https://api.github.com/repos/mendixlabs/google-maps/milestones{/number}","notifications_url":"https://api.github.com/repos/mendixlabs/google-maps/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mendixlabs/google-maps/labels{/name}","releases_url":"https://api.github.com/repos/mendixlabs/google-maps/releases{/id}","deployments_url":"https://api.github.com/repos/mendixlabs/google-maps/deployments","created_at":"2016-10-05T11:26:38Z","updated_at":"2016-10-05T11:27:26Z","pushed_at":"2016-12-01T11:10:58Z","git_url":"git://github.com/mendixlabs/google-maps.git","ssh_url":"git@github.com:mendixlabs/google-maps.git","clone_url":"https://github.com/mendixlabs/google-maps.git","svn_url":"https://github.com/mendixlabs/google-maps","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mendixlabs/google-maps/pulls/2"},"html":{"href":"https://github.com/mendixlabs/google-maps/pull/2"},"issue":{"href":"https://api.github.com/repos/mendixlabs/google-maps/issues/2"},"comments":{"href":"https://api.github.com/repos/mendixlabs/google-maps/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/mendixlabs/google-maps/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/mendixlabs/google-maps/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mendixlabs/google-maps/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/mendixlabs/google-maps/statuses/67fef2c11d91d125414e19fcc0bcd9c4a8c7ddff"}}}}
{"actor":{"display_login":"mijay"}}