-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding tests, coverage, fixing security, JS doc
- Loading branch information
Travis CI
committed
Nov 9, 2021
1 parent
e7fb668
commit 0e1fc25
Showing
16 changed files
with
27,065 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
# Defines the Output Bundle Path for the "npm run dev" target. | ||
# It is recommended to point it directly to the SPM jscript folder. | ||
# For example: %SPM_ROOT_PATH%/webclient/WebContent/CDEJ/jscript/SPMUIComponents | ||
# Defines the Output Bundle Path for the "npm run dev" target. |
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,6 +1,11 @@ | ||
# Dependency directories | ||
node_modules/ | ||
dist/ | ||
coverage/ | ||
reports/ | ||
config/ | ||
|
||
# storybook | ||
storybook-static/ | ||
storybook-static/ | ||
|
||
.DS_STORE |
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,72 @@ | ||
/* | ||
* Licensed Materials - Property of IBM | ||
* | ||
* PID 5725-H26 | ||
* | ||
* Copyright IBM Corporation 2021. All Rights Reserved. | ||
* | ||
* US Government Users Restricted Rights - Use, duplication or disclosure | ||
* restricted by GSA ADP Schedule Contract with IBM Corp. | ||
*/ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import cx from 'classnames'; | ||
import settings from '../../settings'; | ||
|
||
/** | ||
* Example component. | ||
* <p> | ||
* A logo component that renders an image within a circle. A typical usage pattern for this component | ||
* would be for the avatar of a person. | ||
* @namespace Logo | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} Logo | ||
* @memberof Logo | ||
* @property {node} children Child node(s). This is required. An 'img' node i a typical child node | ||
* @property {string} className CSS class name to be added to class list. This is optional. | ||
* @property {string} size The size of logo. Accepted values are 'small', 'mdeium', or 'large'. | ||
* This is optional and the default is medium. | ||
* @property {Object} other Addtional properties that can be added to the rendered logo. The attributes | ||
* will be passed straigh through and added to the rendered ouput. | ||
*/ | ||
const Logo = ({ children, className, size, ...other }) => { | ||
const styleClass = cx( | ||
`${settings.prefix}--logo`, | ||
{ | ||
[`${settings.prefix}--logo--large`]: size === 'large', | ||
[`${settings.prefix}--logo--medium`]: size === 'medium', | ||
[`${settings.prefix}--logo--small`]: size === 'small', | ||
}, | ||
className | ||
); | ||
return ( | ||
<div className={styleClass} {...other}> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
Logo.propTypes = { | ||
/** | ||
* Pass in the image that will be rendered within the Logo | ||
*/ | ||
children: PropTypes.node.isRequired, | ||
/** | ||
* Additional styling | ||
*/ | ||
className: PropTypes.string, | ||
/** | ||
* Specify an optional size for the Logo. Defaults to 'medium' | ||
*/ | ||
size: PropTypes.oneOf(['small', 'medium', 'large']), | ||
}; | ||
|
||
Logo.defaultProps = { | ||
size: 'medium', | ||
className: undefined, | ||
}; | ||
|
||
export default Logo; |
2 changes: 1 addition & 1 deletion
2
src/react/Logo/Logo.stories.js → src/react/examples/Logo/Logo.stories.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
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,73 @@ | ||
/* | ||
* Licensed Materials - Property of IBM | ||
* | ||
* PID 5725-H26 | ||
* | ||
* Copyright IBM Corporation 2020. All Rights Reserved. | ||
* | ||
* US Government Users Restricted Rights - Use, duplication or disclosure | ||
* restricted by GSA ADP Schedule Contract with IBM Corp. | ||
*/ | ||
|
||
import { mount } from 'enzyme'; | ||
import React from 'react';import Logo from '../Logo'; | ||
import settings from '../../../settings'; | ||
|
||
|
||
describe('Logo tests', () => { | ||
it('tests Logo 1 children node', () => { | ||
const smallLogo = mount( | ||
<Logo size="small"> | ||
<img src="../sample-logo.jpg" alt="small logo" /> | ||
</Logo> | ||
); | ||
const logoDiv = smallLogo.find('div'); | ||
// check that the root div exists | ||
expect(logoDiv.exists()).toBeTruthy(); | ||
// check class name on root div | ||
expect( | ||
logoDiv.hasClass(`${settings.prefix}--logo`) | ||
).toBeTruthy(); | ||
expect( | ||
logoDiv.hasClass(`${settings.prefix}--logo--small`) | ||
).toBeTruthy(); | ||
|
||
// check child nodes | ||
expect(logoDiv.at(0).children().length).toBe(1); | ||
// 1st node | ||
expect(logoDiv.at(0).childAt(0).type()).toBe("img"); | ||
// testing the number of attributes are corrcet | ||
const imgAtts = logoDiv.at(0).childAt(0).props(); | ||
expect(Object.keys(imgAtts).length).toBe(2); | ||
expect(logoDiv.at(0).childAt(0).props().src).toBe("../sample-logo.jpg"); | ||
expect(logoDiv.at(0).childAt(0).props().alt).toBe("small logo"); | ||
}); | ||
|
||
it('tests Logo all attributes', () => { | ||
const largeLogo = mount( | ||
<Logo size="large" className="settings.prefix--logo--extraextra" id="logo_123"> | ||
<img src="../sample-logo.jpg" alt="small logo" /> | ||
</Logo> | ||
); | ||
const logoDiv = largeLogo.find('div'); | ||
// check that the root div exists | ||
expect(logoDiv.exists()).toBeTruthy(); | ||
// check class name on root div | ||
|
||
const divAtts = logoDiv.at(0).props(); | ||
expect(Object.keys(divAtts).length).toBe(3); | ||
|
||
expect(logoDiv.at(0).props().className).toBe("bx--logo bx--logo--large settings.prefix--logo--extraextra"); | ||
expect(logoDiv.at(0).props().id).toBe("logo_123"); | ||
// this is the child nodes not an attribute | ||
expect(typeof logoDiv.at(0).props().children !== 'string').toBeTruthy(); | ||
// check child nodes | ||
expect(logoDiv.at(0).children().length).toBe(1); | ||
|
||
// child node already tested previoussly | ||
}); | ||
|
||
}); | ||
|
||
|
||
|
File renamed without changes.
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
File renamed without changes.
Oops, something went wrong.