-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(apiQueries,reduxHelpers): issues/380 query schema
* apiQueries, reduxHelpers, parse queries for specific API endpoints * openshiftView, rhelView, apply parseRhsmQuery
- Loading branch information
Showing
14 changed files
with
165 additions
and
31 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
29 changes: 29 additions & 0 deletions
29
src/redux/common/__tests__/__snapshots__/apiQueries.test.js.snap
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 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ApiQueries should have specific functions: apiQueries 1`] = ` | ||
Object { | ||
"parseRhsmQuery": [Function], | ||
} | ||
`; | ||
|
||
exports[`ApiQueries should parse a query object into specific api facets: rhsm 1`] = ` | ||
Object { | ||
"graphQuery": Object { | ||
"granularity": "daily", | ||
}, | ||
"inventoryQuery": Object { | ||
"limit": 10, | ||
"offset": 0, | ||
}, | ||
"query": Object { | ||
"granularity": "daily", | ||
"limit": 10, | ||
"offset": 0, | ||
}, | ||
"toolbarQuery": Object { | ||
"granularity": "daily", | ||
"limit": 10, | ||
"offset": 0, | ||
}, | ||
} | ||
`; |
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,20 @@ | ||
import { apiQueries } from '../apiQueries'; | ||
import { | ||
RHSM_API_QUERY_GRANULARITY_TYPES as GRANULARITY_TYPES, | ||
RHSM_API_QUERY_TYPES | ||
} from '../../../types/rhsmApiTypes'; | ||
|
||
describe('ApiQueries', () => { | ||
it('should have specific functions', () => { | ||
expect(apiQueries).toMatchSnapshot('apiQueries'); | ||
}); | ||
|
||
it('should parse a query object into specific api facets', () => { | ||
const rhsmApiQuery = { | ||
[RHSM_API_QUERY_TYPES.GRANULARITY]: GRANULARITY_TYPES.DAILY, | ||
[RHSM_API_QUERY_TYPES.LIMIT]: 10, | ||
[RHSM_API_QUERY_TYPES.OFFSET]: 0 | ||
}; | ||
expect(apiQueries.parseRhsmQuery(rhsmApiQuery)).toMatchSnapshot('rhsm'); | ||
}); | ||
}); |
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,26 @@ | ||
import { rhsmApiTypes } from '../../types/rhsmApiTypes'; | ||
import { reduxHelpers } from './reduxHelpers'; | ||
|
||
/** | ||
* Parse a query object against a schema for specific RHSM endpoints. | ||
* | ||
* @param {object} query | ||
* @returns {{query: {}, graphQuery: {}, inventoryQuery: {}, toolbarQuery: {}}} | ||
*/ | ||
const parseRhsmQuery = (query = {}) => { | ||
const graphQuery = reduxHelpers.setApiQuery(query, rhsmApiTypes.RHSM_API_QUERY_SET_REPORT_CAPACITY_TYPES); | ||
const inventoryQuery = reduxHelpers.setApiQuery(query, rhsmApiTypes.RHSM_API_QUERY_SET_INVENTORY_TYPES); | ||
|
||
return { | ||
query, | ||
graphQuery, | ||
inventoryQuery, | ||
toolbarQuery: query | ||
}; | ||
}; | ||
|
||
const apiQueries = { | ||
parseRhsmQuery | ||
}; | ||
|
||
export { apiQueries as default, apiQueries }; |
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,4 @@ | ||
import { apiQueries } from './apiQueries'; | ||
import { reduxHelpers } from './reduxHelpers'; | ||
|
||
export { reduxHelpers as default, reduxHelpers, apiQueries }; |
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.