Skip to content

Commit

Permalink
fix #1135 added floor method to get back real value (#1165)
Browse files Browse the repository at this point in the history
* fix #1135 added floor method to get back real value

* fix added test
  • Loading branch information
saidaipparla authored and mbarto committed Oct 17, 2016
1 parent 02f3acf commit fb0cc20
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ var MousePositionLabelDMS = React.createClass({
let [latM, lngM] = [(lat % 1) * 60, (lng % 1) * 60];
let [latS, lngS] = [(latM % 1) * 60, (lngM % 1) * 60];
return {
lat,
lat: Math.floor(lat),
latM: Math.abs(latM),
latS: Math.abs(latS),
lng,
lng: Math.floor(lng),
lngM: Math.abs(lngM),
lngS: Math.abs(lngS)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,31 @@ describe('MousePosition', () => {
expect(spy.calls.length).toBe(1);
});

it('checks lat ang lag value', () => {

// creating a copy to clipboard callback to spy on
const actions = {
onCopy: () => {}
};
let spy = expect.spyOn(actions, "onCopy");

// instaciating mouse position plugin
const cmp = ReactDOM.render(<MousePosition
enabled={true}
mousePosition={{x: Math.floor(1.1), y: Math.floor(1.2), crs: "EPSG:4326"}}
copyToClipboardEnabled={true}
onCopy={actions.onCopy}
/>, document.getElementById("container"));
// getting the copy to clipboard button
const cmpDom = ReactDOM.findDOMNode(cmp);
const button = cmpDom.getElementsByTagName('button')[0];

// if propmt for ctrl+c we accept
expect.spyOn(window, 'prompt').andReturn(true);

// checking copy to clipboard invocation
button.click();
expect(spy.calls.length).toBe(1);
});

});

0 comments on commit fb0cc20

Please sign in to comment.