Skip to content

Commit b6241e1

Browse files
authored
Add jest test generator (#3828)
* change * add jest tests generator * revert readme
1 parent 609524c commit b6241e1

File tree

44 files changed

+1543
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1543
-45
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ lerna-debug.log
2424
*.sublime-workspace
2525
.history
2626
.vscode
27+
.yo-rc.json
2728

2829
# IDE - VSCode
2930
.vscode

packages/patternfly-4/react-core/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"build:babel:umd": "BABEL_ENV=umd babel --source-maps --extensions \".js\" dist/esm --out-dir dist/umd --plugins=transform-es2015-modules-umd",
3737
"build:types": "tsc -p tsconfig.gen-dts.json",
3838
"clean": "rimraf dist",
39-
"develop": "yarn build:babel:esm --skip-initial-build --watch --verbose"
39+
"develop": "yarn build:babel:esm --skip-initial-build --watch --verbose",
40+
"gen:tests": "yo tsx-docgen"
4041
},
4142
"dependencies": {
4243
"@patternfly/react-icons": "^3.15.3",
@@ -65,9 +66,11 @@
6566
"babel-plugin-typescript-to-proptypes": "^0.17.1",
6667
"css": "^2.2.3",
6768
"fs-extra": "^6.0.1",
69+
"generator-tsx-docgen": "^0.1.0",
6870
"glob": "^7.1.2",
6971
"rimraf": "^2.6.2",
70-
"typescript": "3.4.5"
72+
"typescript": "3.4.5",
73+
"yo": "^3.1.1"
7174
},
7275
"peerDependencies": {
7376
"prop-types": "^15.6.1",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* This test was generated
3+
*/
4+
import * as React from 'react';
5+
import { shallow } from 'enzyme';
6+
import { DataToolbar } from '../../DataToolbar';
7+
// any missing imports can usually be resolved by adding them here
8+
import {} from '../..';
9+
10+
it('DataToolbar should match snapshot (auto-generated)', () => {
11+
const view = shallow(
12+
<DataToolbar
13+
clearAllFilters={() => undefined as void}
14+
clearFiltersButtonText={'string'}
15+
collapseListedFiltersBreakpoint={'md'}
16+
isExpanded={true}
17+
toggleIsExpanded={() => undefined as void}
18+
className={'string'}
19+
children={<div>ReactNode</div>}
20+
id={'string'}
21+
/>
22+
);
23+
expect(view).toMatchSnapshot();
24+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* This test was generated
3+
*/
4+
import * as React from 'react';
5+
import { shallow } from 'enzyme';
6+
import { DataToolbarChipGroupContent } from '../../DataToolbarChipGroupContent';
7+
// any missing imports can usually be resolved by adding them here
8+
import {} from '../..';
9+
10+
it('DataToolbarChipGroupContent should match snapshot (auto-generated)', () => {
11+
const view = shallow(
12+
<DataToolbarChipGroupContent
13+
className={'string'}
14+
isExpanded={true}
15+
chipGroupContentRef={{ current: document.createElement('div') }}
16+
clearAllFilters={() => undefined as void}
17+
showClearFiltersButton={true}
18+
clearFiltersButtonText={"'Clear all filters'"}
19+
numberOfFilters={42}
20+
collapseListedFiltersBreakpoint={'lg'}
21+
/>
22+
);
23+
expect(view).toMatchSnapshot();
24+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* This test was generated
3+
*/
4+
import * as React from 'react';
5+
import { shallow } from 'enzyme';
6+
import { DataToolbarContent } from '../../DataToolbarContent';
7+
// any missing imports can usually be resolved by adding them here
8+
import {} from '../..';
9+
10+
it('DataToolbarContent should match snapshot (auto-generated)', () => {
11+
const view = shallow(
12+
<DataToolbarContent
13+
className={'string'}
14+
breakpointMods={[]}
15+
children={<div>ReactNode</div>}
16+
isExpanded={false}
17+
clearAllFilters={() => undefined as void}
18+
showClearFiltersButton={false}
19+
clearFiltersButtonText={'string'}
20+
toolbarId={'string'}
21+
/>
22+
);
23+
expect(view).toMatchSnapshot();
24+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* This test was generated
3+
*/
4+
import * as React from 'react';
5+
import { shallow } from 'enzyme';
6+
import { DataToolbarExpandableContent } from '../../DataToolbarExpandableContent';
7+
// any missing imports can usually be resolved by adding them here
8+
import {} from '../..';
9+
10+
it('DataToolbarExpandableContent should match snapshot (auto-generated)', () => {
11+
const view = shallow(
12+
<DataToolbarExpandableContent
13+
className={'string'}
14+
isExpanded={false}
15+
expandableContentRef={{ current: document.createElement('div') }}
16+
chipContainerRef={{ current: document.createElement('div') }}
17+
clearAllFilters={() => undefined as void}
18+
clearFiltersButtonText={"'Clear all filters'"}
19+
showClearFiltersButton={true}
20+
/>
21+
);
22+
expect(view).toMatchSnapshot();
23+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* This test was generated
3+
*/
4+
import * as React from 'react';
5+
import { shallow } from 'enzyme';
6+
import { DataToolbarFilter } from '../../DataToolbarFilter';
7+
// any missing imports can usually be resolved by adding them here
8+
import { DataToolbarChip } from '../..';
9+
import { DataToolbarContext } from '../../DataToolbarUtils';
10+
11+
it('DataToolbarFilter should match snapshot (auto-generated)', () => {
12+
const view = shallow(
13+
<DataToolbarContext.Provider
14+
value={{
15+
updateNumberFilters: () => {}
16+
}}
17+
>
18+
<DataToolbarFilter
19+
chips={[]}
20+
deleteChip={(category: string, chip: DataToolbarChip | string) => undefined as void}
21+
children={<div>ReactNode</div>}
22+
categoryName={'string'}
23+
showToolbarItem={true}
24+
/>
25+
</DataToolbarContext.Provider>
26+
);
27+
expect(view).toMatchSnapshot();
28+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* This test was generated
3+
*/
4+
import * as React from 'react';
5+
import { shallow } from 'enzyme';
6+
import { DataToolbarGroup } from '../../DataToolbarGroup';
7+
// any missing imports can usually be resolved by adding them here
8+
import {} from '../..';
9+
10+
it('DataToolbarGroup should match snapshot (auto-generated)', () => {
11+
const view = shallow(
12+
<DataToolbarGroup
13+
className={'string'}
14+
variant={'filter-group'}
15+
breakpointMods={[]}
16+
children={<div>ReactNode</div>}
17+
innerRef={{ current: document.createElement('div') }}
18+
/>
19+
);
20+
expect(view).toMatchSnapshot();
21+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* This test was generated
3+
*/
4+
import * as React from 'react';
5+
import { shallow } from 'enzyme';
6+
import { DataToolbarItem } from '../../DataToolbarItem';
7+
// any missing imports can usually be resolved by adding them here
8+
import {} from '../..';
9+
10+
it('DataToolbarItem should match snapshot (auto-generated)', () => {
11+
const view = shallow(
12+
<DataToolbarItem
13+
className={'string'}
14+
variant={'separator'}
15+
breakpointMods={[]}
16+
id={'string'}
17+
children={<div>ReactNode</div>}
18+
/>
19+
);
20+
expect(view).toMatchSnapshot();
21+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* This test was generated
3+
*/
4+
import * as React from 'react';
5+
import { shallow } from 'enzyme';
6+
import { DataToolbarToggleGroup } from '../../DataToolbarToggleGroup';
7+
// any missing imports can usually be resolved by adding them here
8+
import {} from '../..';
9+
10+
it('DataToolbarToggleGroup should match snapshot (auto-generated)', () => {
11+
const view = shallow(
12+
<DataToolbarToggleGroup toggleIcon={<div>ReactNode</div>} breakpoint={'md'} breakpointMods={[]} />
13+
);
14+
expect(view).toMatchSnapshot();
15+
});

0 commit comments

Comments
 (0)