Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #25537 - Layout unwanted action calls
- Loading branch information
Showing
12 changed files
with
184 additions
and
76 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
11 changes: 8 additions & 3 deletions
11
webpack/assets/javascripts/react_app/components/Layout/__tests__/LayoutHelper.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,13 +1,18 @@ | ||
import { combineMenuItems, getActiveOnBack } from '../LayoutHelper'; | ||
import { combineMenuItems, getActive, handleMenuClick } from '../LayoutHelper'; | ||
import { layoutMock } from '../Layout.fixtures'; | ||
|
||
describe('LayoutHelper', () => { | ||
it('should combineMenuItems', () => { | ||
const combined = combineMenuItems(layoutMock.data); | ||
expect(combined).toMatchSnapshot(); | ||
}); | ||
it('should getActiveOnBack(Monitor)', () => { | ||
const active = getActiveOnBack(layoutMock.data.menu, '/fact_values'); | ||
it('should getActive(Monitor)', () => { | ||
const active = getActive(layoutMock.data.menu, '/fact_values'); | ||
expect(active).toMatchSnapshot(); | ||
}); | ||
it('should handleMenuClick', () => { | ||
const change = jest.fn(); | ||
handleMenuClick({ title: 'Host' }, 'Infra', change); | ||
expect(change).toHaveBeenCalled(); | ||
}); | ||
}); |
43 changes: 27 additions & 16 deletions
43
webpack/assets/javascripts/react_app/components/Layout/__tests__/LayoutSelectors.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,27 +1,38 @@ | ||
import { patternflyMenuItemsSelector } from '../LayoutSelectors'; | ||
import { testSelectorsSnapshotWithFixtures } from '../../../common/testHelpers'; | ||
import { | ||
patternflyMenuItemsSelector, | ||
selectIsLoading, | ||
selectLayout, | ||
selectCurrentLocation, | ||
selectCurrentOrganization, | ||
} from '../LayoutSelectors'; | ||
import { layoutMock } from '../Layout.fixtures'; | ||
|
||
const state = { | ||
layout: { | ||
items: layoutMock.data.menu, | ||
activeMenu: 'Hosts', | ||
currentOrganization: { title: 'org1' }, | ||
currentLocation: { title: 'loc1' }, | ||
isLoading: true, | ||
}, | ||
}; | ||
describe('Layout Selectors', () => { | ||
it('should return PF-React Compatible items', () => { | ||
const output = patternflyMenuItemsSelector(state); | ||
|
||
expect(output).toMatchSnapshot(); | ||
}); | ||
it('should return empty array', () => { | ||
const emptyState = { | ||
layout: { | ||
items: [], | ||
}, | ||
}; | ||
const output = patternflyMenuItemsSelector(emptyState); | ||
const emptyState = { | ||
layout: { | ||
items: [], | ||
}, | ||
}; | ||
|
||
const fixtures = { | ||
'should return Layout': () => selectLayout(state), | ||
'should return PF-React Compatible items': () => patternflyMenuItemsSelector(state), | ||
'should return empty array of items': () => patternflyMenuItemsSelector(emptyState), | ||
|
||
'should return isLoading from selector': () => selectIsLoading(state), | ||
'should return location from selector': () => selectCurrentLocation(state), | ||
'should return organization from selector': () => selectCurrentOrganization(state), | ||
}; | ||
|
||
describe('Layout selectors', () => testSelectorsSnapshotWithFixtures(fixtures)); | ||
|
||
expect(output).toMatchSnapshot(); | ||
}); | ||
}); |
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
Oops, something went wrong.