Skip to content

Commit

Permalink
RELATED: FET-6 React 15.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
David Ocetnik authored and Tomáš Vojtášek committed Mar 12, 2018
1 parent cd7f3a8 commit bd4cac0
Show file tree
Hide file tree
Showing 17 changed files with 1,195 additions and 490 deletions.
5 changes: 5 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
const enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-15');

enzyme.configure({ adapter: new Adapter() });

// Fail test on console error (react proptypes validation etc.)
const consoleError = console.error;
console.error = (err, ...args) => {
Expand Down
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,54 @@
"devDependencies": {
"@gooddata/mock-js": "1.0.0-alpha3",
"@gooddata/test-storybook": "1.1.0",
"@gooddata/typings": "1.0.0",
"@gooddata/typings": "2.0.0-alpha0",
"@storybook/addon-actions": "3.2.18",
"@storybook/addon-options": "3.2.6",
"@storybook/react": "3.2.6",
"@storybook/react": "3.3.10",
"@types/classnames": "2.2.3",
"@types/enzyme": "2.8.8",
"@types/enzyme": "3.1.6",
"@types/enzyme-adapter-react-15": "1.0.1",
"@types/jest": "20.0.4",
"@types/lodash": "4.14.61",
"@types/node": "7.0.8",
"@types/prop-types": "15.5.2",
"@types/react": "16.0.7",
"@types/react-addons-test-utils": "0.14.17",
"@types/react-dom": "15.5.4",
"@types/react-intl": "2.3.2",
"@types/react": "16.0.34",
"@types/react-dom": "16.0.3",
"@types/react-intl": "2.3.5",
"@types/react-test-renderer": "16.0.0",
"@types/storybook__addon-actions": "3.0.1",
"@types/storybook__react": "3.0.5",
"enzyme": "2.8.0",
"@types/storybook__react": "3.0.6",
"enzyme": "3.3.0",
"enzyme-adapter-react-15": "1.0.5",
"jest": "21.2.1",
"jest-junit": "3.0.0",
"node-sass": "4.7.2",
"node-sass-magic-importer": "5.1.0",
"react": "15.3.2",
"react-addons-test-utils": "15.3.2",
"react-dom": "15.3.2",
"react": "15.6.2",
"react-dom": "15.6.2",
"react-test-renderer": "15.6.2",
"sass-loader": "6.0.6",
"ts-jest": "21.2.4",
"ts-loader": "2.3.7",
"tslint-config-gooddata": "0.0.8",
"typescript": "2.3.3"
},
"dependencies": {
"@gooddata/data-layer": "7.0.0-alpha0",
"@gooddata/goodstrap": "54.0.0-alpha2",
"@gooddata/indigo-visualizations": "^1.3.2",
"@gooddata/data-layer": "7.0.0-alpha2",
"@gooddata/goodstrap": "55.0.0-alpha0",
"@gooddata/indigo-visualizations": "2.0.0-alpha0",
"@gooddata/js-utils": "^0.9.0",
"@gooddata/numberjs": "^3.1.2",
"classnames": "^2.2.5",
"gooddata": "6.0.0-alpha0",
"gooddata": "6.0.0-alpha1",
"lodash": "^4.17.4",
"prop-types": "^15.6.0",
"react-intl": "^2.2.3",
"react-intl": "^2.4.0",
"rxjs": "^5.5.6"
},
"peerDependencies": {
"react": "15.3.2",
"react-dom": "15.3.2"
"react": "15.6.2",
"react-dom": "15.6.2"
},
"config": {
"tslint": "'./{src,stories}/**/*.{ts,tsx}'"
Expand Down
1 change: 1 addition & 0 deletions src/components/afm/tests/BarChart.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('BarChart', () => {
/>);

return delay().then(() => {
wrapper.update();
const dimensions = wrapper.find(CoreBarChart).props().resultSpec.dimensions;
expect(dimensions).toEqual([ { itemIdentifiers: ['measureGroup'] }, { itemIdentifiers: ['a1'] } ]);
});
Expand Down
1 change: 1 addition & 0 deletions src/components/afm/tests/ColumnChart.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('ColumnChart', () => {
/>));

return delay().then(() => {
wrapper.update();
const dimensions = wrapper.find(CoreColumnChart).props().resultSpec.dimensions;
expect(dimensions).toEqual([{ itemIdentifiers: ['measureGroup'] }, { itemIdentifiers: ['a1'] }]);
});
Expand Down
16 changes: 14 additions & 2 deletions src/components/afm/tests/DataSourceProvider.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('DataSourceProvider', () => {
const wrapper = createComponent(Table);

return delay().then(() => {
wrapper.update();
const table = wrapper.find(Table);
expect(table.length).toEqual(1);

Expand All @@ -50,11 +51,14 @@ describe('DataSourceProvider', () => {
resultSpec: {}
};
return delay().then(() => {
wrapper.update();
const table = wrapper.find(Table);
const tableProps: IDataSourceProviderInjectedProps = table.props();
const oldDataSource = tableProps.dataSource;
wrapper.setProps(newProps);
return delay().then(() => {
wrapper.update();
const table = wrapper.find(Table);
const tableProps = table.props() as IDataSourceProviderInjectedProps;
expect(table.length).toEqual(1);
expect(tableProps.dataSource).not.toBe(oldDataSource);
Expand All @@ -72,11 +76,14 @@ describe('DataSourceProvider', () => {
};

return delay().then(() => {
wrapper.update();
const table = wrapper.find(Table);
const tableProps: IDataSourceProviderInjectedProps = table.props();
const oldDataSource = tableProps.dataSource;
wrapper.setProps(newProps);
return delay().then(() => {
wrapper.update();
const table = wrapper.find(Table);
const tableProps: IDataSourceProviderInjectedProps = table.props();
expect(table.length).toEqual(1);
expect(tableProps.dataSource).not.toBe(oldDataSource);
Expand Down Expand Up @@ -106,10 +113,12 @@ describe('DataSourceProvider', () => {
};

return delay().then(() => {
const node: any = wrapper.getNode();
const prepareDataSourceSpy = jest.spyOn(node, 'prepareDataSource');
wrapper.update();
const instance: any = wrapper.instance();
const prepareDataSourceSpy = jest.spyOn(instance, 'prepareDataSource');
wrapper.setProps(newProps);
return delay().then(() => {
wrapper.update();
expect(prepareDataSourceSpy).toHaveBeenCalledTimes(1);
});
});
Expand All @@ -119,8 +128,10 @@ describe('DataSourceProvider', () => {
const wrapper = createComponent(Table);

return delay().then(() => {
wrapper.update();
wrapper.setState({ dataSource: null });
return delay().then(() => {
wrapper.update();
expect(wrapper.find(Table).length).toEqual(0);
});
});
Expand All @@ -132,6 +143,7 @@ describe('DataSourceProvider', () => {
const wrapper = mount(<WrappedTable {...defaultProps} />);

return delay().then(() => {
wrapper.update();
expect(wrapper.find(Table).props().resultSpec.dimensions).toEqual(defaultDimension());
});
});
Expand Down
1 change: 1 addition & 0 deletions src/components/afm/tests/LineChart.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('LineChart', () => {
/>));

return delay().then(() => {
wrapper.update();
const dimensions = wrapper.find(CoreLineChart).props().resultSpec.dimensions;
expect(dimensions).toEqual([ { itemIdentifiers: ['measureGroup'] }, { itemIdentifiers: ['a1'] } ]);
});
Expand Down
2 changes: 2 additions & 0 deletions src/components/afm/tests/PieChart.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('PieChart', () => {
/>));

return delay().then(() => {
wrapper.update();
const dimensions = wrapper.find(CorePieChart).props().resultSpec.dimensions;
expect(dimensions).toEqual([ { itemIdentifiers: [] }, { itemIdentifiers: ['measureGroup'] } ]);
});
Expand All @@ -40,6 +41,7 @@ describe('PieChart', () => {
/>));

return delay().then(() => {
wrapper.update();
const dimensions = wrapper.find(CorePieChart).props().resultSpec.dimensions;
expect(dimensions).toEqual([ { itemIdentifiers: ['measureGroup'] }, { itemIdentifiers: ['a1'] } ]);
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/afm/tests/Table.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { dummyExecuteAfmAdapterFactory } from './utils/DummyExecuteAfmAdapter';
import { executionRequest } from './utils/dummyFixture';

describe('Table', () => {

it('should provide default resultSpec to the core Table with attributes', () => {
const wrapper = mount((
<Table
Expand All @@ -17,6 +16,7 @@ describe('Table', () => {
/>));

return delay().then(() => {
wrapper.update();
const dimensions = wrapper.find(SortableTable).props().resultSpec.dimensions;
expect(dimensions).toEqual([
{ itemIdentifiers: ['departmentAttribute'] },
Expand Down
4 changes: 2 additions & 2 deletions src/components/core/SortableTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export class SortableTable extends React.Component<ITableProps, ISortableTableSt
pushData: noop
};

constructor() {
super();
constructor(props: ITableProps) {
super(props);

this.state = {
sortItems: []
Expand Down
1 change: 1 addition & 0 deletions src/components/core/base/test/BaseChart.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('BaseChart', () => {
const wrapper = createComponent(props);

return delay().then(() => {
wrapper.update();
const visualization = wrapper.find(Visualization);

expect(visualization.length).toBe(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('VisualizationLoadingHOC', () => {
const wrapper = createComponent(props);

return delay().then(() => {
wrapper.update();
const inner = wrapper.find(TestInnerComponent);
expect(inner.length).toBe(1);
expect(inner.props()).toMatchObject(props);
Expand Down Expand Up @@ -124,6 +125,7 @@ describe('VisualizationLoadingHOC', () => {
const wrapper = createComponent();

return delay().then(() => {
wrapper.update();
const inner = wrapper.find(TestInnerComponent);
expect(inner.length).toBe(1);
expect(inner.props()).toMatchObject({
Expand All @@ -143,6 +145,7 @@ describe('VisualizationLoadingHOC', () => {
});

return delay().then(() => {
wrapper.update();
const innerWrapped = wrapper.find(TestInnerComponent);
const innerError = wrapper.find(ErrorComponent);

Expand Down Expand Up @@ -259,6 +262,7 @@ describe('VisualizationLoadingHOC', () => {
});

return delay().then(() => {
wrapper.update();
const inner = wrapper.find(TestInnerComponent);

onError.mockReset();
Expand Down Expand Up @@ -312,6 +316,7 @@ describe('VisualizationLoadingHOC', () => {
});

return delay().then(() => {
wrapper.update();
expect(wrapper.find(TestInnerComponent).length).toBe(0);
expect(onError).toHaveBeenCalledTimes(2);
expect(onError).toHaveBeenLastCalledWith({
Expand All @@ -323,6 +328,7 @@ describe('VisualizationLoadingHOC', () => {
dataSource: oneMeasureDataSource
});
return delay().then(() => {
wrapper.update();
expect(pushData).toHaveBeenCalledTimes(1);
expect(wrapper.find(TestInnerComponent).length).toBe(1);
});
Expand All @@ -336,6 +342,7 @@ describe('VisualizationLoadingHOC', () => {
});

return delay().then(() => {
wrapper.update();
const visualization = wrapper.find(TestInnerComponent);
onError.mockReset();

Expand Down
1 change: 1 addition & 0 deletions src/components/core/tests/Headline.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('Headline', () => {
const wrapper = createComponent();

return delay().then(() => {
wrapper.update();
const renderdHeadlineTrans = wrapper.find(HeadlineTransformation);
const wrapperProps = wrapper.props();
expect(renderdHeadlineTrans.props()).toMatchObject({
Expand Down
Loading

0 comments on commit bd4cac0

Please sign in to comment.