Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResizeGroup should apply className from props #3450

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@uifabric/experiments",
"comment": "Apply props.className in ResizeGroup. Add snapshot for ResizeGroup. Pass className from experiments CommandBarTests. Update experiments CommandBar snapshot",
"type": "patch"
}
],
"packageName": "@uifabric/experiments",
"email": "staylo@microsoft.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Apply props.className in ResizeGroup. Add snapshot for ResizeGroup. Pass className from experiments CommandBarTests. Update experiments CommandBar snapshot",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "staylo@microsoft.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('CommandBar', () => {
{ key: '1', name: 'asdf' },
{ key: '2', name: 'asdf' }
] }
className={ 'TestClassName' }
/>
).toJSON()).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`CommandBar renders commands correctly 1`] = `
<div
className="ms-ResizeGroup"
className="ms-ResizeGroup TestClassName"
>
<div
className=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { shallow } from 'enzyme';
import { ResizeGroup, IResizeGroupState, getNextResizeGroupStateProvider, getMeasurementCache } from './ResizeGroup';
import { IResizeGroupProps } from './ResizeGroup.types';
import * as sinon from 'sinon';
import * as renderer from 'react-test-renderer';

interface ITestScalingData {
scalingIndex: number;
Expand All @@ -24,6 +25,20 @@ function getRequiredResizeGroupProps() {
}

describe('ResizeGroup', () => {
it('renders the ResizeGroup correctly', () => {
const initialData = { content: 5 };
const renderedDataId = 'onRenderDataId';
const onRenderData = (data: any) => <div id={ renderedDataId }> Rendered data: { data.content }</div >;
expect(renderer.create(
<ResizeGroup
data={ initialData }
onReduceData={ onReduceScalingData }
onRenderData={ onRenderData }
className={ 'TestClassName' }
/>
).toJSON()).toMatchSnapshot();
});

it('renders the result of onRenderData', () => {
const initialData = { content: 5 };
const renderedDataId = 'onRenderDataId';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,11 @@ export class ResizeGroup extends BaseComponent<IResizeGroupProps, IResizeGroupSt
}

public render() {
const { onRenderData } = this.props;
const { onRenderData, className } = this.props;
const { dataToMeasure, renderedData } = this.state;

return (
<div className={ css('ms-ResizeGroup') } ref={ this._resolveRef('_root') }>
<div className={ css('ms-ResizeGroup', className) } ref={ this._resolveRef('_root') }>
{ this._nextResizeGroupStateProvider.shouldRenderDataToMeasureInHiddenDiv(dataToMeasure) && (
<div className={ css(styles.measured) } ref={ this._resolveRef('_measured') }>
{ onRenderData(dataToMeasure) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ResizeGroup renders the ResizeGroup correctly 1`] = `
<div
className="ms-ResizeGroup TestClassName"
>
<div
className=""
>
<div
id="onRenderDataId"
>
Rendered data:
5
</div>
</div>
</div>
`;