-
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.
Browse files
Browse the repository at this point in the history
* locale strings * toolbarFieldSla, Usage, standalone select fields
- Loading branch information
Showing
8 changed files
with
537 additions
and
1 deletion.
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
89 changes: 89 additions & 0 deletions
89
src/components/toolbar/__tests__/__snapshots__/toolbarFieldSla.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,89 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ToolbarFieldSla Component should export select options: toolbarFieldOptions 1`] = ` | ||
Array [ | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.sla, {\\"context\\":\\"premium\\"})", | ||
"value": "premium", | ||
}, | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.sla, {\\"context\\":\\"standard\\"})", | ||
"value": "standard", | ||
}, | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.sla, {\\"context\\":\\"self-support\\"})", | ||
"value": "self-support", | ||
}, | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.sla, {\\"context\\":\\"none\\"})", | ||
"value": "", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`ToolbarFieldSla Component should handle updating sla through redux state: dispatch sla 1`] = ` | ||
Array [ | ||
Array [ | ||
Array [ | ||
Object { | ||
"type": "SET_QUERY_RESET_INVENTORY_LIST", | ||
"viewId": "loremIpsum", | ||
}, | ||
Object { | ||
"sla": "premium", | ||
"type": "SET_QUERY_RHSM_sla", | ||
"viewId": "loremIpsum", | ||
}, | ||
], | ||
], | ||
] | ||
`; | ||
|
||
exports[`ToolbarFieldSla Component should render a basic component: basic 1`] = ` | ||
<Select | ||
aria-label="t(curiosity-toolbar.placeholder, {\\"context\\":\\"sla\\"})" | ||
ariaLabel="Select option" | ||
className="" | ||
data-test="toolbarFieldSla" | ||
direction="down" | ||
id="generatedid-" | ||
isDisabled={false} | ||
isToggleText={true} | ||
maxHeight={null} | ||
name={null} | ||
onSelect={[Function]} | ||
options={ | ||
Array [ | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.sla, {\\"context\\":\\"premium\\"})", | ||
"value": "premium", | ||
}, | ||
Object { | ||
"selected": true, | ||
"title": "t(curiosity-toolbar.sla, {\\"context\\":\\"standard\\"})", | ||
"value": "standard", | ||
}, | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.sla, {\\"context\\":\\"self-support\\"})", | ||
"value": "self-support", | ||
}, | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.sla, {\\"context\\":\\"none\\"})", | ||
"value": "", | ||
}, | ||
] | ||
} | ||
placeholder="t(curiosity-toolbar.placeholder, {\\"context\\":\\"sla\\"})" | ||
position="left" | ||
selectedOptions="standard" | ||
toggleIcon={null} | ||
variant="single" | ||
/> | ||
`; |
89 changes: 89 additions & 0 deletions
89
src/components/toolbar/__tests__/__snapshots__/toolbarFieldUsage.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,89 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ToolbarFieldSla Component should export select options: toolbarFieldOptions 1`] = ` | ||
Array [ | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.usage, {\\"context\\":\\"Production\\"})", | ||
"value": "Production", | ||
}, | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.usage, {\\"context\\":\\"Development/Test\\"})", | ||
"value": "Development/Test", | ||
}, | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.usage, {\\"context\\":\\"Disaster Recovery\\"})", | ||
"value": "Disaster Recovery", | ||
}, | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.usage, {\\"context\\":\\"unspecified\\"})", | ||
"value": "", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`ToolbarFieldSla Component should handle updating usage through redux state: dispatch usage 1`] = ` | ||
Array [ | ||
Array [ | ||
Array [ | ||
Object { | ||
"type": "SET_QUERY_RESET_INVENTORY_LIST", | ||
"viewId": "loremIpsum", | ||
}, | ||
Object { | ||
"type": "SET_QUERY_RHSM_usage", | ||
"usage": "Production", | ||
"viewId": "loremIpsum", | ||
}, | ||
], | ||
], | ||
] | ||
`; | ||
|
||
exports[`ToolbarFieldSla Component should render a basic component: basic 1`] = ` | ||
<Select | ||
aria-label="t(curiosity-toolbar.placeholder, {\\"context\\":\\"usage\\"})" | ||
ariaLabel="Select option" | ||
className="" | ||
data-test="toolbarFieldUsage" | ||
direction="down" | ||
id="generatedid-" | ||
isDisabled={false} | ||
isToggleText={true} | ||
maxHeight={null} | ||
name={null} | ||
onSelect={[Function]} | ||
options={ | ||
Array [ | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.usage, {\\"context\\":\\"Production\\"})", | ||
"value": "Production", | ||
}, | ||
Object { | ||
"selected": true, | ||
"title": "t(curiosity-toolbar.usage, {\\"context\\":\\"Development/Test\\"})", | ||
"value": "Development/Test", | ||
}, | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.usage, {\\"context\\":\\"Disaster Recovery\\"})", | ||
"value": "Disaster Recovery", | ||
}, | ||
Object { | ||
"selected": false, | ||
"title": "t(curiosity-toolbar.usage, {\\"context\\":\\"unspecified\\"})", | ||
"value": "", | ||
}, | ||
] | ||
} | ||
placeholder="t(curiosity-toolbar.placeholder, {\\"context\\":\\"usage\\"})" | ||
position="left" | ||
selectedOptions="Development/Test" | ||
toggleIcon={null} | ||
variant="single" | ||
/> | ||
`; |
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,45 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { ToolbarFieldSla, toolbarFieldOptions } from '../toolbarFieldSla'; | ||
import { store } from '../../../redux/store'; | ||
import { RHSM_API_QUERY_SLA_TYPES as SLA_TYPES, RHSM_API_QUERY_TYPES } from '../../../types/rhsmApiTypes'; | ||
|
||
describe('ToolbarFieldSla Component', () => { | ||
let mockDispatch; | ||
|
||
beforeEach(() => { | ||
mockDispatch = jest.spyOn(store, 'dispatch').mockImplementation((type, data) => ({ type, data })); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should render a basic component', () => { | ||
const props = { | ||
useProduct: () => ({ viewId: 'loremIpsum' }), | ||
useProductQuery: () => ({ [RHSM_API_QUERY_TYPES.SLA]: SLA_TYPES.STANDARD }) | ||
}; | ||
const component = shallow(<ToolbarFieldSla {...props} />); | ||
|
||
expect(component).toMatchSnapshot('basic'); | ||
}); | ||
|
||
it('should export select options', () => { | ||
expect(toolbarFieldOptions).toMatchSnapshot('toolbarFieldOptions'); | ||
}); | ||
|
||
it('should handle updating sla through redux state', async () => { | ||
const props = { | ||
useProduct: () => ({ viewId: 'loremIpsum' }) | ||
}; | ||
|
||
const component = await mountHookComponent(<ToolbarFieldSla {...props} />); | ||
|
||
component.find('button').simulate('click'); | ||
component.update(); | ||
component.find('button.pf-c-select__menu-item').first().simulate('click'); | ||
|
||
expect(mockDispatch.mock.calls).toMatchSnapshot('dispatch sla'); | ||
}); | ||
}); |
45 changes: 45 additions & 0 deletions
45
src/components/toolbar/__tests__/toolbarFieldUsage.test.js
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,45 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { ToolbarFieldUsage, toolbarFieldOptions } from '../toolbarFieldUsage'; | ||
import { store } from '../../../redux/store'; | ||
import { RHSM_API_QUERY_USAGE_TYPES as USAGE_TYPES, RHSM_API_QUERY_TYPES } from '../../../types/rhsmApiTypes'; | ||
|
||
describe('ToolbarFieldSla Component', () => { | ||
let mockDispatch; | ||
|
||
beforeEach(() => { | ||
mockDispatch = jest.spyOn(store, 'dispatch').mockImplementation((type, data) => ({ type, data })); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should render a basic component', () => { | ||
const props = { | ||
useProduct: () => ({ viewId: 'loremIpsum' }), | ||
useProductQuery: () => ({ [RHSM_API_QUERY_TYPES.USAGE]: USAGE_TYPES.DEVELOPMENT }) | ||
}; | ||
const component = shallow(<ToolbarFieldUsage {...props} />); | ||
|
||
expect(component).toMatchSnapshot('basic'); | ||
}); | ||
|
||
it('should export select options', () => { | ||
expect(toolbarFieldOptions).toMatchSnapshot('toolbarFieldOptions'); | ||
}); | ||
|
||
it('should handle updating usage through redux state', async () => { | ||
const props = { | ||
useProduct: () => ({ viewId: 'loremIpsum' }) | ||
}; | ||
|
||
const component = await mountHookComponent(<ToolbarFieldUsage {...props} />); | ||
|
||
component.find('button').simulate('click'); | ||
component.update(); | ||
component.find('button.pf-c-select__menu-item').first().simulate('click'); | ||
|
||
expect(mockDispatch.mock.calls).toMatchSnapshot('dispatch usage'); | ||
}); | ||
}); |
Oops, something went wrong.