-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
71274a9
commit 6165bb3
Showing
17 changed files
with
239 additions
and
114 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
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
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
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
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
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
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
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
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
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
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
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
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
57 changes: 57 additions & 0 deletions
57
web/client/components/widgets/widget/__tests__/TextWidget-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,57 @@ | ||
/* | ||
* Copyright 2018, 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. | ||
*/ | ||
|
||
const React = require('react'); | ||
const ReactDOM = require('react-dom'); | ||
const ReactTestUtils = require('react-dom/test-utils'); | ||
|
||
const expect = require('expect'); | ||
const TextWidget = require('../TextWidget'); | ||
|
||
describe('TextWidget component', () => { | ||
beforeEach((done) => { | ||
document.body.innerHTML = '<div id="container"></div>'; | ||
setTimeout(done); | ||
}); | ||
afterEach((done) => { | ||
ReactDOM.unmountComponentAtNode(document.getElementById("container")); | ||
document.body.innerHTML = ''; | ||
setTimeout(done); | ||
}); | ||
it('rendering with defaults', () => { | ||
ReactDOM.render(<TextWidget />, document.getElementById("container")); | ||
const container = document.getElementById('container'); | ||
const el = container.querySelector('.mapstore-widget-card'); | ||
expect(container.querySelector('.glyphicon-pencil')).toExist(); | ||
expect(container.querySelector('.glyphicon-trash')).toExist(); | ||
expect(el).toExist(); | ||
}); | ||
it('view only mode', () => { | ||
ReactDOM.render(<TextWidget canEdit={false} />, document.getElementById("container")); | ||
const container = document.getElementById('container'); | ||
expect(container.querySelector('.glyphicon-pencil')).toNotExist(); | ||
expect(container.querySelector('.glyphicon-trash')).toNotExist(); | ||
}); | ||
it('onEdit callback', () => { | ||
const actions = { | ||
onEdit: () => {} | ||
}; | ||
const spyonEdit = expect.spyOn(actions, 'onEdit'); | ||
ReactDOM.render(<TextWidget onEdit={actions.onEdit} />, document.getElementById("container")); | ||
const container = document.getElementById('container'); | ||
const el = container.querySelector('.glyphicon-pencil'); | ||
ReactTestUtils.Simulate.click(el); // <-- trigger event callback | ||
expect(spyonEdit).toHaveBeenCalled(); | ||
}); | ||
it('rendering text', () => { | ||
const TEST_TEXT = '<div id="TEST_TEXT"> TEST </div>'; | ||
ReactDOM.render(<TextWidget text={TEST_TEXT} />, document.getElementById("container")); | ||
const container = document.getElementById('container'); | ||
expect(container.querySelector('#TEST_TEXT')).toExist(); | ||
}); | ||
}); |
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
Oops, something went wrong.