-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
209 additions
and
2 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
39 changes: 39 additions & 0 deletions
39
web/client/components/data/featuregrid/editors/__tests__/AutocompleteEditor-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,39 @@ | ||
const React = require('react'); | ||
const ReactDOM = require('react-dom'); | ||
const AutocompleteEditor = require('../AutocompleteEditor'); | ||
const {createPagedUniqueAutompleteStream} = require('../../../../../observables/autocomplete'); | ||
|
||
var expect = require('expect'); | ||
|
||
let testColumn = { | ||
key: 'columnKey' | ||
}; | ||
const value = "1.1"; | ||
describe('FeatureGrid AutocompleteEditor 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('AutocompleteEditor Editor no stream provided', () => { | ||
const cmp = ReactDOM.render(<AutocompleteEditor | ||
value={value} | ||
rowIdx={1} | ||
column={testColumn}/>, document.getElementById("container")); | ||
expect(cmp.getValue().columnKey).toBe(value); | ||
expect(cmp.validate(value)).toBe(true); | ||
}); | ||
it('AutocompleteEditor Editor no stream provided', () => { | ||
const cmp = ReactDOM.render(<AutocompleteEditor | ||
value={value} | ||
rowIdx={1} | ||
autocompleteStreamFactory={createPagedUniqueAutompleteStream} | ||
column={testColumn}/>, document.getElementById("container")); | ||
expect(cmp).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
29 changes: 29 additions & 0 deletions
29
web/client/components/misc/__tests__/AutocompleteCombobox-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,29 @@ | ||
/* | ||
* Copyright 2017, 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 expect = require('expect'); | ||
const React = require('react'); | ||
const ReactDOM = require('react-dom'); | ||
const {AutocompleteCombobox} = require('../AutocompleteCombobox'); | ||
const {createPagedUniqueAutompleteStream} = require('../../../observables/autocomplete'); | ||
|
||
describe("This test for AutocompleteCombobox 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('creates AutocompleteCombobox with defaults', () => { | ||
const comp = ReactDOM.render(<AutocompleteCombobox autocompleteStreamFactory={createPagedUniqueAutompleteStream}/>, document.getElementById("container")); | ||
expect(comp).toExist(); | ||
}); | ||
|
||
}); |
139 changes: 139 additions & 0 deletions
139
web/client/components/misc/__tests__/PagedCombobox-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,139 @@ | ||
/* | ||
* Copyright 2017, 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 expect = require('expect'); | ||
const React = require('react'); | ||
const ReactDOM = require('react-dom'); | ||
const PagedCombobox = require('../PagedCombobox'); | ||
const TestUtils = require('react-dom/test-utils'); | ||
const {Tooltip} = require('react-bootstrap'); | ||
|
||
describe("This test for PagedCombobox 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('creates PagedCombobox with defaults', () => { | ||
const comp = ReactDOM.render(<PagedCombobox/>, document.getElementById("container")); | ||
expect(comp).toExist(); | ||
|
||
const input = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "rw-input")[0]); | ||
// triggering default actions | ||
TestUtils.Simulate.change(input, { | ||
target: { | ||
value: "other" | ||
} | ||
}); | ||
TestUtils.Simulate.focus(input); | ||
|
||
}); | ||
it('creates PagedCombobox with defaults and with basic tooltip', () => { | ||
const tooltip = { | ||
message: "wow", | ||
enabled: true, | ||
id: "1", | ||
overlayTriggerKey: "key", | ||
placement: "top" | ||
}; | ||
const comp = ReactDOM.render(<PagedCombobox tooltip={tooltip}/>, document.getElementById("container")); | ||
expect(comp).toExist(); | ||
}); | ||
it('creates PagedCombobox with defaults and with customized tooltip', () => { | ||
const tooltip = <Tooltip id={"wonderfulId"}>"a message for the tooltip"</Tooltip>; | ||
|
||
const comp = ReactDOM.render(<PagedCombobox tooltip={{customizedTooltip: tooltip}}/>, document.getElementById("container")); | ||
expect(comp).toExist(); | ||
}); | ||
it('tests PagedCombobox onToggle and opening of option lists', () => { | ||
const actions = { | ||
onToggle: () => {} | ||
}; | ||
const spy = expect.spyOn(actions, "onToggle"); | ||
const data = [{ | ||
label: "label", value: "value" | ||
}]; | ||
const comp = ReactDOM.render(<PagedCombobox onToggle={actions.onToggle} data={data}/>, document.getElementById("container")); | ||
expect(comp).toExist(); | ||
const domNode = ReactDOM.findDOMNode(comp); | ||
expect(domNode).toExist(); | ||
const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "rw-i rw-i-caret-down")[0]); | ||
tool.click(); | ||
expect(spy.calls.length).toBe(1); | ||
// this tests if the option list is opened | ||
const firstOption = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "rw-list-option")[0]); | ||
expect(firstOption).toExist(); | ||
const valueOption = firstOption.getElementsByTagName("span")[0]; | ||
expect(valueOption).toExist(); | ||
expect(valueOption.innerText).toBe("label"); | ||
}); | ||
it('tests PagedCombobox onChange', () => { | ||
const actions = { | ||
onChange: () => {} | ||
}; | ||
const spy = expect.spyOn(actions, "onChange"); | ||
const data = [{ | ||
label: "label", value: "value" | ||
}]; | ||
const comp = ReactDOM.render(<PagedCombobox onChange={actions.onChange} data={data}/>, document.getElementById("container")); | ||
expect(comp).toExist(); | ||
const input = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "rw-input")[0]); | ||
TestUtils.Simulate.change(input, { | ||
target: { | ||
value: "other" | ||
} | ||
}); | ||
expect(spy.calls.length).toBe(1); | ||
}); | ||
it('tests PagedCombobox onFocus', (done) => { | ||
const actions = { | ||
onFocus: () => {} | ||
}; | ||
const spy = expect.spyOn(actions, "onFocus"); | ||
const data = [{ | ||
label: "label", value: "value" | ||
}]; | ||
const comp = ReactDOM.render(<PagedCombobox onFocus={actions.onFocus} data={data}/>, document.getElementById("container")); | ||
expect(comp).toExist(); | ||
const input = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "rw-input")[0]); | ||
TestUtils.Simulate.focus(input); | ||
setTimeout(() => { | ||
expect(spy.calls.length).toEqual(1); | ||
done(); | ||
}, 50); | ||
}); | ||
|
||
it('tests PagedCombobox onSelect and opening of option lists', (done) => { | ||
const actions = { | ||
onSelect: () => {} | ||
}; | ||
const spy = expect.spyOn(actions, "onSelect"); | ||
const data = [{ | ||
label: "label", value: "value" | ||
}]; | ||
const comp = ReactDOM.render(<PagedCombobox onSelect={actions.onSelect} data={data}/>, document.getElementById("container")); | ||
expect(comp).toExist(); | ||
const domNode = ReactDOM.findDOMNode(comp); | ||
expect(domNode).toExist(); | ||
const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "rw-i rw-i-caret-down")[0]); | ||
tool.click(); | ||
// this tests if the option list is opened | ||
const firstOption = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "rw-list-option")[0]); | ||
expect(firstOption).toExist(); | ||
const valueOption = firstOption.getElementsByTagName("span")[0]; | ||
expect(valueOption).toExist(); | ||
TestUtils.Simulate.click(firstOption); | ||
setTimeout(() => { | ||
expect(spy.calls.length).toEqual(1); | ||
done(); | ||
}, 50); | ||
}); | ||
}); |