forked from theforeman/foreman
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #30784 - replace memory allocation input to react comp
- Loading branch information
1 parent
9d44364
commit 8a9922f
Showing
12 changed files
with
113 additions
and
147 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
57 changes: 20 additions & 37 deletions
57
...cripts/react_app/components/MemoryAllocationInput/__tests__/MemoryAllocationInput.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 |
---|---|---|
@@ -1,46 +1,29 @@ | ||
import React from 'react'; | ||
import { mount } from '@theforeman/test'; | ||
import { testComponentSnapshotsWithFixtures } from '../../../common/testHelpers'; | ||
import MemoryAllocationInput from '../MemoryAllocationInput'; | ||
import { Provider } from 'react-redux'; | ||
import MemoryAllocationInput from '../'; | ||
import Store from "../../../redux"; | ||
|
||
const props = { | ||
label: 'Memory', | ||
}; | ||
|
||
const fixtures = { | ||
'should render with default props': props, | ||
}; | ||
|
||
describe('MemoryAllocationInput', () => { | ||
describe('rendering', () => { | ||
testComponentSnapshotsWithFixtures(MemoryAllocationInput, fixtures); | ||
}); | ||
|
||
it('MB to GB change', async () => { | ||
const component = mount(<MemoryAllocationInput defaultValue={768} />); | ||
expect(component.find('input').prop('value')).toEqual('768 MB'); | ||
component | ||
.find('.foreman-numeric-input-handler-up') | ||
.at(0) | ||
.simulate('mousedown'); | ||
|
||
component.update(); | ||
expect(component.find('input').prop('value')).toEqual('1 GB'); | ||
it('warning alert', async () => { | ||
const component = mount( | ||
<Provider store={Store}> | ||
<MemoryAllocationInput defaultValue={11264} recommendedMaxValue={10240} /> | ||
</Provider> | ||
); | ||
expect(component.find('.foreman-numeric-input-input').prop('value')).toEqual('11264 MB'); | ||
expect(component.find('.warning-icon').exists()).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
it('warning alert', async () => { | ||
const component = mount( | ||
<MemoryAllocationInput defaultValue={11264} recommendedMaxValue={10240} /> | ||
); | ||
expect(component.find('input').prop('value')).toEqual('11 GB'); | ||
expect(component.find('.warning-icon').exists()).toBeTruthy(); | ||
}); | ||
|
||
it('error alert', async () => { | ||
const component = mount( | ||
<MemoryAllocationInput defaultValue={21504} maxValue={20480} /> | ||
); | ||
expect(component.find('input').prop('value')).toEqual('21 GB'); | ||
expect(component.find('.error-icon').exists()).toBeTruthy(); | ||
it('error alert', async () => { | ||
const component = mount( | ||
<Provider store={Store}> | ||
<MemoryAllocationInput defaultValue={21504} maxValue={20480} /> | ||
</Provider> | ||
); | ||
expect(component.find('.foreman-numeric-input-input').prop('value')).toEqual('21504 MB'); | ||
expect(component.find('.error-icon').exists()).toBeTruthy(); | ||
}); | ||
}); |
50 changes: 0 additions & 50 deletions
50
...mponents/MemoryAllocationInput/__tests__/__snapshots__/MemoryAllocationInput.test.js.snap
This file was deleted.
Oops, something went wrong.
6 changes: 1 addition & 5 deletions
6
webpack/assets/javascripts/react_app/components/MemoryAllocationInput/constants.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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
export const GB_FORMAT = 'GB'; | ||
|
||
export const MB_FORMAT = 'MB'; | ||
|
||
export const GB_STEP = 1024; | ||
|
||
export const MB_STEP = 256; | ||
export const MEGABYTES = 1048576; |
4 changes: 4 additions & 0 deletions
4
.../assets/javascripts/react_app/components/MemoryAllocationInput/memoryAllocationInput.scss
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.