-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from sandydoo/update-ember
- Loading branch information
Showing
10 changed files
with
123 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,6 @@ | |
|
||
# addons | ||
/.node_modules.ember-try/ | ||
|
||
# docs | ||
/docs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,20 @@ | ||
import GMap from 'ember-google-maps/components/g-map'; | ||
import { | ||
clearMapInstances, | ||
getMapInstance, | ||
} from 'ember-google-maps/utils/helpers'; | ||
import { settled } from '@ember/test-helpers'; | ||
import { action } from '@ember/object'; | ||
|
||
let lastKey; | ||
const MAP_STORE = new Map(); | ||
|
||
function addToStore(id, map) { | ||
MAP_STORE.set(id, map); | ||
lastKey = id; | ||
} | ||
|
||
function getFromStore(id) { | ||
if (id) { | ||
return MAP_STORE.get(id); | ||
} | ||
|
||
return MAP_STORE.get(lastKey); | ||
} | ||
|
||
function resetStore() { | ||
MAP_STORE.clear(); | ||
} | ||
|
||
export async function waitForMap(id) { | ||
await settled(); | ||
return getFromStore(id); | ||
} | ||
|
||
export function setupMapTest(hooks) { | ||
hooks.beforeEach(function () { | ||
this.waitForMap = waitForMap.bind(this); | ||
|
||
// TODO can we do this from within g-map? I guess the main issue with that | ||
// is figuring out how to remove all this code from the production build. | ||
this.owner.register( | ||
'component:g-map', | ||
class InstrumentedGMap extends GMap { | ||
@action | ||
getCanvas(canvas) { | ||
super.getCanvas(canvas); | ||
addToStore(canvas.id, this.publicAPI); | ||
} | ||
} | ||
); | ||
}); | ||
|
||
hooks.afterEach(function () { | ||
resetStore(); | ||
clearMapInstances(); | ||
}); | ||
} | ||
|
||
export async function waitForMap(id) { | ||
await settled(); | ||
return getMapInstance(id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
export function toLatLng(lat, lng) { | ||
import { | ||
clearMapInstances, | ||
getMapInstance, | ||
} from '../component-managers/map-component-manager'; | ||
|
||
function toLatLng(lat, lng) { | ||
return lat && lng && google?.maps | ||
? new google.maps.LatLng(lat, lng) | ||
: undefined; | ||
} | ||
|
||
export { clearMapInstances, getMapInstance, toLatLng }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { toLatLng } from 'ember-google-maps/utils/helpers'; | ||
export { toLatLng, getMapInstance } from 'ember-google-maps/utils/helpers'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters