-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic tests for ZoomToMaxExtentButton
- Loading branch information
1 parent
e536d8a
commit 58daa4b
Showing
2 changed files
with
81 additions
and
6 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
76 changes: 76 additions & 0 deletions
76
web/client/components/buttons/__tests__/ZoomToMaxExtentButton-test.jsx
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* Copyright 2015, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
var React = require('react/addons'); | ||
var ZoomToMaxExtentButton = require('../ZoomToMaxExtentButton'); | ||
var expect = require('expect'); | ||
|
||
// initializes Redux store | ||
var Provider = require('react-redux').Provider; | ||
var store = require('./../../../examples/myapp/stores/myappstore'); | ||
|
||
describe('This test for ZoomToMaxExtentButton', () => { | ||
afterEach((done) => { | ||
React.unmountComponentAtNode(document.body); | ||
document.body.innerHTML = ''; | ||
setTimeout(done); | ||
}); | ||
|
||
// test DEFAULTS | ||
it('test default properties', () => { | ||
const zmeBtn = React.render( | ||
<Provider store={store}> | ||
{() => <ZoomToMaxExtentButton/>} | ||
</Provider>, | ||
document.body); | ||
expect(zmeBtn).toExist(); | ||
|
||
const zmeBtnNode = React.findDOMNode(zmeBtn); | ||
expect(zmeBtnNode).toExist(); | ||
expect(zmeBtnNode.id).toBe("mapstore-zoomtomaxextent"); | ||
|
||
expect(zmeBtnNode).toExist(); | ||
expect(zmeBtnNode.className.indexOf('default') >= 0).toBe(true); | ||
expect(zmeBtnNode.innerHTML).toExist(); | ||
}); | ||
|
||
it('test glyphicon property', () => { | ||
const zmeBtn = React.render( | ||
<Provider store={store}> | ||
{() => <ZoomToMaxExtentButton/>} | ||
</Provider>, | ||
document.body); | ||
expect(zmeBtn).toExist(); | ||
|
||
const zmeBtnNode = React.findDOMNode(zmeBtn); | ||
expect(zmeBtnNode).toExist(); | ||
expect(zmeBtnNode).toExist(); | ||
const icons = zmeBtnNode.getElementsByTagName('span'); | ||
expect(icons.length).toBe(1); | ||
}); | ||
|
||
it('test glyphicon property with text', () => { | ||
const zmeBtn = React.render( | ||
<Provider store={store}> | ||
{() => <ZoomToMaxExtentButton glyphicon="info-sign" text="button"/>} | ||
</Provider>, | ||
document.body); | ||
expect(zmeBtn).toExist(); | ||
|
||
const zmeBtnNode = React.findDOMNode(zmeBtn); | ||
expect(zmeBtnNode).toExist(); | ||
expect(zmeBtnNode).toExist(); | ||
|
||
const btnItems = zmeBtnNode.getElementsByTagName('span'); | ||
expect(btnItems.length).toBe(3); | ||
|
||
expect(btnItems[0].innerHTML).toBe(""); | ||
expect(btnItems[1].innerHTML).toBe(" "); | ||
expect(btnItems[2].innerHTML).toBe("button"); | ||
}); | ||
|
||
}); |