Skip to content

Commit

Permalink
test(Text): Add demo and integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccaalpert committed May 9, 2019
1 parent 3b5f0f1 commit 6b42986
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 5 deletions.
Expand Up @@ -17,7 +17,7 @@ export enum TextVariants {

export interface TextProps extends React.HTMLProps<HTMLElement> {
/** The text component */
component?: keyof TextVariants;
component?: TextVariants;
/** Content rendered within the Text */
children?: React.ReactNode;
/** Additional classes added to the Text */
Expand Down
8 changes: 4 additions & 4 deletions packages/patternfly-4/react-core/src/components/Text/index.ts
@@ -1,4 +1,4 @@
export { TextContent } from './TextContent';
export { Text, TextVariants } from './Text';
export { TextList, TextListVariants } from './TextList';
export { TextListItem, TextListItemVariants } from './TextListItem';
export * from './TextContent';
export * from './Text';
export * from './TextList';
export * from './TextListItem';
@@ -0,0 +1,19 @@
describe('Text Demo Test', () => {
it('Navigate to demo section', () => {
cy.visit('http://localhost:3000/');
cy.get('#text-demo-nav-item-link').click();
cy.url().should('eq', 'http://localhost:3000/text-demo-nav-link')
});

it('Verify header text and text content', () => {
cy.get('.pf-c-content h1').contains('Header text');
});

it('Verify text list and text content', () => {
cy.get('.pf-c-content ul').contains('li');
});

it('Verify text list item and text content', () => {
cy.get('.pf-c-content li').contains('Text list item');
});
});
Expand Up @@ -40,6 +40,11 @@ export const Demos: DemoInterface[] = [
name: 'Tab Demo',
componentType: Examples.TabDemo
},
{
id: 'text-demo',
name: 'Text Demo',
componentType: Examples.TextDemo
},
{
id: 'title-demo',
name: 'Title Demo',
Expand Down
@@ -0,0 +1,28 @@
import { Text, TextProps, TextVariants, TextContent, TextList, TextListProps, TextListVariants, TextListItem, TextListItemProps, TextListItemVariants } from '@patternfly/react-core';
import React, { Component } from 'react';
export class TextDemo extends Component {
myTextProps: TextProps = {
component: TextVariants.h1,
children: 'Header text'
}
myTextListProps: TextListProps = {
component: TextListItemVariants.ul
}
myTextListItemProps: TextListItemProps = {
component: TextListItemVariants.li,
children: 'Text list item'
}

render() {
return (
<TextContent>
<Text component={this.myTextProps.component}>{this.myTextProps.children}</Text>
<TextList component={this.myTextListProps.component}>
<TextListItem children={this.myTextListItemProps.children} component={this.myTextListItemProps.component} />
</TextList>
</TextContent>
);
}
}

export default TextDemo;
Expand Up @@ -4,6 +4,7 @@ export * from './LabelDemo/LabelDemo';
export * from './NavDemo/NavDemo';
export * from './PopoverDemo/PopoverDemo'
export * from './TabsDemo/TabsDemo';
export * from './TextDemo/TextDemo';
export * from './TitleDemo/TitleDemo';
export * from './TooltipDemo/TooltipDemo';
export * from './WizardDemo/WizardDemo';

0 comments on commit 6b42986

Please sign in to comment.