-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Externalized maptype selectors (#1817)
* Externalized maptype selectors to improve testability and reusability * add documentation for selectors
- Loading branch information
1 parent
c4112e5
commit ab6ea7e
Showing
4 changed files
with
68 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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 {mapTypeSelector, isCesium} = require('../maptype'); | ||
|
||
describe('Test maptype', () => { | ||
it('test mapTypeSelector', () => { | ||
const mapType = mapTypeSelector({maptype: {mapType: "cesium"}}); | ||
|
||
expect(mapType).toExist(); | ||
expect(mapType).toBe("cesium"); | ||
}); | ||
|
||
it('test isCesium', () => { | ||
const bool = isCesium({maptype: {mapType: "cesium"}}); | ||
expect(bool).toExist(); | ||
expect(bool).toBe(true); | ||
expect(isCesium({maptype: {mapType: "leaflet"}})).toBe(false); | ||
}); | ||
}); |
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. | ||
*/ | ||
|
||
/** | ||
* selects maptype from state | ||
* @memberof selectors.maptype | ||
* @param {object} state the state | ||
* @return {string} the maptype in the state | ||
*/ | ||
const mapTypeSelector = (state) => state && state.maptype && state.maptype.mapType; | ||
|
||
/** | ||
* Check if the mapType is cesium | ||
* @function | ||
* @memberof selectors.maptype | ||
* @param {object} state the state | ||
* @return {boolean} | ||
*/ | ||
const isCesium = state => mapTypeSelector(state) === "cesium"; | ||
|
||
module.exports = { | ||
mapTypeSelector, | ||
isCesium | ||
}; |