Tests for getGeoUri (#7400)

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Andy Balaam 2021-12-17 10:58:24 +00:00 committed by GitHub
parent f389324571
commit bd226cd062
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 96 additions and 10 deletions

View file

@ -185,21 +185,12 @@ class LocationPicker extends React.Component<IProps, IState> {
this.setState({ description: ev.target.value });
};
private getGeoUri = (position) => {
return (`geo:${ position.coords.latitude },` +
position.coords.longitude +
( position.coords.altitude !== undefined ?
`,${ position.coords.altitude }` : '' ) +
( position.coords.accuracy !== undefined ?
`;u=${ position.coords.accuracy }` : '' ));
};
private onOk = () => {
const position = (this.state.type == LocationShareType.Custom) ?
this.state.manualPosition : this.state.position;
this.props.onChoose(
position ? this.getGeoUri(position) : undefined,
position ? getGeoUri(position) : undefined,
position ? position.timestamp : undefined,
this.state.type,
this.state.description,
@ -263,4 +254,13 @@ class LocationPicker extends React.Component<IProps, IState> {
}
}
export function getGeoUri(position: GeolocationPosition): string {
return (`geo:${ position.coords.latitude },` +
position.coords.longitude +
( position.coords.altitude !== undefined ?
`,${ position.coords.altitude }` : '' ) +
( position.coords.accuracy !== undefined ?
`;u=${ position.coords.accuracy }` : '' ));
}
export default LocationPicker;