Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #1135 added floor method to get back real value #1165

Merged
merged 2 commits into from
Oct 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});

});