Skip to content

Commit

Permalink
Add jest test generator (#3828)
Browse files Browse the repository at this point in the history
* change

* add jest tests generator

* revert readme
  • Loading branch information
jschuler authored Feb 26, 2020
1 parent 609524c commit b6241e1
Show file tree
Hide file tree
Showing 44 changed files with 1,543 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ lerna-debug.log
*.sublime-workspace
.history
.vscode
.yo-rc.json

# IDE - VSCode
.vscode
Expand Down
7 changes: 5 additions & 2 deletions packages/patternfly-4/react-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"build:babel:umd": "BABEL_ENV=umd babel --source-maps --extensions \".js\" dist/esm --out-dir dist/umd --plugins=transform-es2015-modules-umd",
"build:types": "tsc -p tsconfig.gen-dts.json",
"clean": "rimraf dist",
"develop": "yarn build:babel:esm --skip-initial-build --watch --verbose"
"develop": "yarn build:babel:esm --skip-initial-build --watch --verbose",
"gen:tests": "yo tsx-docgen"
},
"dependencies": {
"@patternfly/react-icons": "^3.15.3",
Expand Down Expand Up @@ -65,9 +66,11 @@
"babel-plugin-typescript-to-proptypes": "^0.17.1",
"css": "^2.2.3",
"fs-extra": "^6.0.1",
"generator-tsx-docgen": "^0.1.0",
"glob": "^7.1.2",
"rimraf": "^2.6.2",
"typescript": "3.4.5"
"typescript": "3.4.5",
"yo": "^3.1.1"
},
"peerDependencies": {
"prop-types": "^15.6.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* This test was generated
*/
import * as React from 'react';
import { shallow } from 'enzyme';
import { DataToolbar } from '../../DataToolbar';
// any missing imports can usually be resolved by adding them here
import {} from '../..';

it('DataToolbar should match snapshot (auto-generated)', () => {
const view = shallow(
<DataToolbar
clearAllFilters={() => undefined as void}
clearFiltersButtonText={'string'}
collapseListedFiltersBreakpoint={'md'}
isExpanded={true}
toggleIsExpanded={() => undefined as void}
className={'string'}
children={<div>ReactNode</div>}
id={'string'}
/>
);
expect(view).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* This test was generated
*/
import * as React from 'react';
import { shallow } from 'enzyme';
import { DataToolbarChipGroupContent } from '../../DataToolbarChipGroupContent';
// any missing imports can usually be resolved by adding them here
import {} from '../..';

it('DataToolbarChipGroupContent should match snapshot (auto-generated)', () => {
const view = shallow(
<DataToolbarChipGroupContent
className={'string'}
isExpanded={true}
chipGroupContentRef={{ current: document.createElement('div') }}
clearAllFilters={() => undefined as void}
showClearFiltersButton={true}
clearFiltersButtonText={"'Clear all filters'"}
numberOfFilters={42}
collapseListedFiltersBreakpoint={'lg'}
/>
);
expect(view).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* This test was generated
*/
import * as React from 'react';
import { shallow } from 'enzyme';
import { DataToolbarContent } from '../../DataToolbarContent';
// any missing imports can usually be resolved by adding them here
import {} from '../..';

it('DataToolbarContent should match snapshot (auto-generated)', () => {
const view = shallow(
<DataToolbarContent
className={'string'}
breakpointMods={[]}
children={<div>ReactNode</div>}
isExpanded={false}
clearAllFilters={() => undefined as void}
showClearFiltersButton={false}
clearFiltersButtonText={'string'}
toolbarId={'string'}
/>
);
expect(view).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* This test was generated
*/
import * as React from 'react';
import { shallow } from 'enzyme';
import { DataToolbarExpandableContent } from '../../DataToolbarExpandableContent';
// any missing imports can usually be resolved by adding them here
import {} from '../..';

it('DataToolbarExpandableContent should match snapshot (auto-generated)', () => {
const view = shallow(
<DataToolbarExpandableContent
className={'string'}
isExpanded={false}
expandableContentRef={{ current: document.createElement('div') }}
chipContainerRef={{ current: document.createElement('div') }}
clearAllFilters={() => undefined as void}
clearFiltersButtonText={"'Clear all filters'"}
showClearFiltersButton={true}
/>
);
expect(view).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* This test was generated
*/
import * as React from 'react';
import { shallow } from 'enzyme';
import { DataToolbarFilter } from '../../DataToolbarFilter';
// any missing imports can usually be resolved by adding them here
import { DataToolbarChip } from '../..';
import { DataToolbarContext } from '../../DataToolbarUtils';

it('DataToolbarFilter should match snapshot (auto-generated)', () => {
const view = shallow(
<DataToolbarContext.Provider
value={{
updateNumberFilters: () => {}
}}
>
<DataToolbarFilter
chips={[]}
deleteChip={(category: string, chip: DataToolbarChip | string) => undefined as void}
children={<div>ReactNode</div>}
categoryName={'string'}
showToolbarItem={true}
/>
</DataToolbarContext.Provider>
);
expect(view).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* This test was generated
*/
import * as React from 'react';
import { shallow } from 'enzyme';
import { DataToolbarGroup } from '../../DataToolbarGroup';
// any missing imports can usually be resolved by adding them here
import {} from '../..';

it('DataToolbarGroup should match snapshot (auto-generated)', () => {
const view = shallow(
<DataToolbarGroup
className={'string'}
variant={'filter-group'}
breakpointMods={[]}
children={<div>ReactNode</div>}
innerRef={{ current: document.createElement('div') }}
/>
);
expect(view).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* This test was generated
*/
import * as React from 'react';
import { shallow } from 'enzyme';
import { DataToolbarItem } from '../../DataToolbarItem';
// any missing imports can usually be resolved by adding them here
import {} from '../..';

it('DataToolbarItem should match snapshot (auto-generated)', () => {
const view = shallow(
<DataToolbarItem
className={'string'}
variant={'separator'}
breakpointMods={[]}
id={'string'}
children={<div>ReactNode</div>}
/>
);
expect(view).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* This test was generated
*/
import * as React from 'react';
import { shallow } from 'enzyme';
import { DataToolbarToggleGroup } from '../../DataToolbarToggleGroup';
// any missing imports can usually be resolved by adding them here
import {} from '../..';

it('DataToolbarToggleGroup should match snapshot (auto-generated)', () => {
const view = shallow(
<DataToolbarToggleGroup toggleIcon={<div>ReactNode</div>} breakpoint={'md'} breakpointMods={[]} />
);
expect(view).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DataToolbar should match snapshot (auto-generated) 1`] = `
<div
className="pf-c-data-toolbar string"
id="string"
>
<ContextProvider
value={
Object {
"chipGroupContentRef": Object {
"current": null,
},
"isExpanded": true,
"numberOfFilters": 0,
"toggleIsExpanded": [Function],
"updateNumberFilters": [Function],
}
}
>
<div
clearAllFilters={[Function]}
clearFiltersButtonText="string"
isExpanded={true}
key=".0"
showClearFiltersButton={false}
toolbarId="string"
>
ReactNode
</div>
<DataToolbarChipGroupContent
chipGroupContentRef={
Object {
"current": null,
}
}
clearAllFilters={[Function]}
clearFiltersButtonText="string"
collapseListedFiltersBreakpoint="md"
isExpanded={true}
numberOfFilters={0}
showClearFiltersButton={false}
/>
</ContextProvider>
</div>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DataToolbarChipGroupContent should match snapshot (auto-generated) 1`] = `
<div
className="pf-c-data-toolbar__content pf-m-hidden string"
hidden={true}
>
<ForwardRef
className=""
/>
</div>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DataToolbarContent should match snapshot (auto-generated) 1`] = `
<div
className="pf-c-data-toolbar__content string"
>
<ContextProvider
value={
Object {
"chipContainerRef": Object {
"current": null,
},
"expandableContentId": "string-expandable-content-0",
"expandableContentRef": Object {
"current": null,
},
}
}
>
<div
className="pf-c-data-toolbar__content-section"
>
<div>
ReactNode
</div>
</div>
<DataToolbarExpandableContent
chipContainerRef={
Object {
"current": null,
}
}
clearAllFilters={[Function]}
clearFiltersButtonText="string"
expandableContentRef={
Object {
"current": null,
}
}
id="string-expandable-content-0"
isExpanded={false}
showClearFiltersButton={false}
/>
</ContextProvider>
</div>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DataToolbarExpandableContent should match snapshot (auto-generated) 1`] = `
<div
className="pf-c-data-toolbar__expandable-content string"
>
<ForwardRef />
</div>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DataToolbarFilter should match snapshot (auto-generated) 1`] = `
<DataToolbarFilter
categoryName="string"
chips={Array []}
deleteChip={[Function]}
showToolbarItem={true}
>
<div>
ReactNode
</div>
</DataToolbarFilter>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DataToolbarGroup should match snapshot (auto-generated) 1`] = `
<DataToolbarGroupWithRef
breakpointMods={Array []}
className="string"
innerRef={null}
variant="filter-group"
>
<div>
ReactNode
</div>
</DataToolbarGroupWithRef>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DataToolbarItem should match snapshot (auto-generated) 1`] = `
<div
className="pf-c-data-toolbar__item pf-m-separator string"
id="string"
>
<div>
ReactNode
</div>
</div>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DataToolbarToggleGroup should match snapshot (auto-generated) 1`] = `
<ContextConsumer>
<Component />
</ContextConsumer>
`;
Loading

0 comments on commit b6241e1

Please sign in to comment.