Skip to content

Commit

Permalink
feat: rename parameter contains bam to a generic name (ENG-54964) (#34)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephen Le <[email protected]>
  • Loading branch information
haihuynh-bluecat and stephenle17 authored May 22, 2024
1 parent 1ae235a commit 6391c8f
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ SOFTWARE.
*/

import { shallow } from 'enzyme';
import HeaderBAM from '../../src/header/HeaderBAM';
import HeaderAuthentication from '../../src/header/HeaderAuthentication';

jest.unmock('../../src/header/HeaderBAM');
jest.unmock('../../src/header/HeaderAuthentication');

jest.mock('../../src/hooks/usePlatformData', () =>
jest.fn(() => {
return {
data: {
user: {
bam_info: {
authentication_info: {
alias: 'Bam1',
url: '192.168.10.2',
},
Expand All @@ -40,15 +40,17 @@ jest.mock('../../src/hooks/usePlatformData', () =>
}),
);

describe('HeaderBAM', () => {
describe('HeaderAuthentication', () => {
describe('Rendering', () => {
it('Render HeaderBAM component with default props', () => {
const wrapper = shallow(<HeaderBAM />);
it('Render HeaderAuthentication component with default props', () => {
const wrapper = shallow(<HeaderAuthentication />);
expect(wrapper.getElement()).toMatchSnapshot();
});

it('Render HeaderBAM component with props', () => {
const wrapper = shallow(<HeaderBAM className='varClassName' />);
it('Render HeaderAuthentication component with props', () => {
const wrapper = shallow(
<HeaderAuthentication className='varClassName' />,
);
expect(wrapper.getElement()).toMatchSnapshot();
});
});
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/__snapshots__/Header.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exports[`Header Rendering Render Header component with default props 1`] = `
<div
className="Header__rightSideMenu"
>
<HeaderBAM />
<HeaderAuthentication />
<HeaderHelpMenu />
<HeaderSystemMenu />
<HeaderAccountMenu />
Expand Down Expand Up @@ -49,7 +49,7 @@ exports[`Header Rendering Render Header component with props 1`] = `
<div
className="Header__rightSideMenu"
>
<HeaderBAM />
<HeaderAuthentication />
<HeaderHelpMenu />
<HeaderSystemMenu />
<HeaderAccountMenu />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`HeaderBAM Rendering Render HeaderBAM component with default props 1`] = `
exports[`HeaderAuthentication Rendering Render HeaderAuthentication component with default props 1`] = `
<React.Fragment>
<div
className="HeaderBAM__bam"
className="HeaderAuthentication__authentication"
>
<span>
BAM  
 
<SvgIcon
icon={
Object {
Expand Down Expand Up @@ -40,13 +40,13 @@ exports[`HeaderBAM Rendering Render HeaderBAM component with default props 1`] =
</React.Fragment>
`;

exports[`HeaderBAM Rendering Render HeaderBAM component with props 1`] = `
exports[`HeaderAuthentication Rendering Render HeaderAuthentication component with props 1`] = `
<React.Fragment>
<div
className="HeaderBAM__bam varClassName"
className="HeaderAuthentication__authentication varClassName"
>
<span>
BAM  
 
<SvgIcon
icon={
Object {
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
'\\.po$': '@bluecateng/l10n-jest',
},
transformIgnorePatterns: [
'node_modules/(?!(lodash-es|@bluecat|@bluecateng)/)',
'node_modules/(?!(lodash-es|@bluecat|@bluecateng|@carbon)/)',
],
collectCoverage: true,
coverageReporters: ['text', 'html'],
Expand Down
4 changes: 2 additions & 2 deletions src/header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import PropTypes from 'prop-types';
import { useEffect } from 'react';
import { Layer } from '@bluecateng/pelagos';
import HeaderAccountMenu from './HeaderAccountMenu';
import HeaderBAM from './HeaderBAM';
import HeaderAuthentication from './HeaderAuthentication';
import HeaderHelpMenu from './HeaderHelpMenu';
import HeaderLogo from './HeaderLogo';
import HeaderSystemMenu from './HeaderSystemMenu';
Expand Down Expand Up @@ -64,7 +64,7 @@ const Header = ({ className }) => {
</div>
<HeaderLogo />
<div className='Header__rightSideMenu'>
<HeaderBAM />
<HeaderAuthentication />
<HeaderHelpMenu />
<HeaderSystemMenu />
<HeaderAccountMenu />
Expand Down
28 changes: 15 additions & 13 deletions src/header/HeaderBAM.js → src/header/HeaderAuthentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,37 @@ import PropTypes from 'prop-types';
import usePlatformData from '../hooks/usePlatformData';
import { SvgIcon } from '@bluecateng/pelagos';
import { faLink } from '@fortawesome/free-solid-svg-icons';
import './HeaderBAM.less';
import './HeaderAuthentication.less';

/**
* HeaderBAM component displays the connected BAM alias and URL. <br>
* HeaderAuthentication component displays the connected Authentication
* service alias and URL. <br>
* This component is intended to be nested inside the PlatformDataContext
* as it will require access to PlatformData.
*/
const HeaderBAM = ({ className }) => {
const HeaderAuthentication = ({ className }) => {
const { data } = usePlatformData();
const bamAlias = data?.user?.bam_info?.alias;
const bamLink = data?.user?.bam_info?.url;
const authenticationAlias = data?.user?.authentication_info?.alias;
const authenticationLink = data?.user?.authentication_info?.url;
const authenticationService = data?.user?.authentication_info?.service;

return (
<>
{bamAlias ? (
{authenticationAlias ? (
<div
className={`HeaderBAM__bam${
className={`HeaderAuthentication__authentication${
className ? ' ' + className : ''
}`}>
<span>
BAM &nbsp;
{authenticationService} &nbsp;
<SvgIcon id='link-icon' icon={faLink} />
&nbsp;
<a
href={bamLink}
href={authenticationLink}
target='_blank'
rel='noreferrer'
title={bamAlias}>
{bamAlias}
title={authenticationAlias}>
{authenticationAlias}
</a>
</span>
</div>
Expand All @@ -60,9 +62,9 @@ const HeaderBAM = ({ className }) => {
);
};

HeaderBAM.propTypes = {
HeaderAuthentication.propTypes = {
/** The component class name(s). */
className: PropTypes.string,
};

export default HeaderBAM;
export default HeaderAuthentication;
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
// SOFTWARE.
@import '~@bluecateng/pelagos/less/spacing';

.HeaderBAM {
&__bam {
.HeaderAuthentication {
&__authentication {
& span {
color: var(--text-secondary);
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SOFTWARE.
*/
export { default as Header } from './Header';
export { default as HeaderAccountMenu } from './HeaderAccountMenu';
export { default as HeaderBAM } from './HeaderBAM';
export { default as HeaderAuthentication } from './HeaderAuthentication';
export { default as HeaderHelpMenu } from './HeaderHelpMenu';
export { default as HeaderHomeNav } from './HeaderHomeNav';
export { default as HeaderLogo } from './HeaderLogo';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import HeaderBAM from '../src/header/HeaderBAM';
import HeaderAuthentication from '../src/header/HeaderAuthentication';
import PlatformDataContext from '../src/components/PlatformDataContext';

const mockValue = {
data: {
user: {
// eslint-disable-next-line camelcase
bam_info: {
authentication_info: {
alias: 'BAM-9.5.0',
url: '#',
},
Expand All @@ -35,8 +35,8 @@ const mockValue = {
};

export default {
title: 'Components/HeaderBAM',
component: HeaderBAM,
title: 'Components/HeaderAuthentication',
component: HeaderAuthentication,
decorators: [
(Story) => (
<PlatformDataContext.Provider value={mockValue}>
Expand All @@ -48,6 +48,6 @@ export default {

export const Normal = {
args: {
className: 'TestHeaderBAM',
className: 'TestHeaderAuthentication',
},
};

0 comments on commit 6391c8f

Please sign in to comment.