Skip to content

Commit

Permalink
fix added test
Browse files Browse the repository at this point in the history
  • Loading branch information
saidaipparla committed Oct 17, 2016
1 parent cffa5c0 commit 3a8d4df
Showing 1 changed file with 27 additions and 0 deletions.
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 3a8d4df

Please sign in to comment.