Skip to content

Commit

Permalink
generate snapshots for tests (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen authored and janhenrikoverland committed Apr 10, 2019
1 parent 9665a5a commit 870486d
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,43 +60,43 @@ describe('The DialogManager component', () => {
expect(dialog.state().ouMounted).toBe(true);
});

// it('renders the DataDimension content in dialog', () => {
// const dialog = dialogManager().setProps({
// dialogId: FIXED_DIMENSIONS.dx.id,
// });
it('renders the DataDimension content in dialog', () => {
const dialog = dialogManager().setProps({
dialogId: FIXED_DIMENSIONS.dx.id,
});

// expect(dialog).toMatchSnapshot();
// });
expect(dialog).toMatchSnapshot();
});

// it('renders the OrgUnitDimension content in dialog', () => {
// const dialog = dialogManager().setProps({
// dialogId: FIXED_DIMENSIONS.ou.id,
// });
it('renders the OrgUnitDimension content in dialog', () => {
const dialog = dialogManager().setProps({
dialogId: FIXED_DIMENSIONS.ou.id,
});

// expect(dialog).toMatchSnapshot();
// });
expect(dialog).toMatchSnapshot();
});

// it('renders the PeriodDimension content in dialog', () => {
// const dialog = dialogManager().setProps({
// dialogId: FIXED_DIMENSIONS.pe.id,
// });
it('renders the PeriodDimension content in dialog', () => {
const dialog = dialogManager().setProps({
dialogId: FIXED_DIMENSIONS.pe.id,
});

// expect(dialog).toMatchSnapshot();
// });
expect(dialog).toMatchSnapshot();
});

// it('renders OUDimension content with display:none when previously mounted', () => {
// const dialog = dialogManager().setProps({
// dialogId: FIXED_DIMENSIONS.ou.id,
// });
it('renders OUDimension content with display:none when previously mounted', () => {
const dialog = dialogManager().setProps({
dialogId: FIXED_DIMENSIONS.ou.id,
});

// expect(dialog).toMatchSnapshot();
expect(dialog).toMatchSnapshot();

// dialog.setProps({ dialogId: null });
// expect(dialog).toMatchSnapshot();
dialog.setProps({ dialogId: null });
expect(dialog).toMatchSnapshot();

// dialog.setProps({ dialogId: FIXED_DIMENSIONS.dx.id });
// expect(dialog).toMatchSnapshot();
// });
dialog.setProps({ dialogId: FIXED_DIMENSIONS.dx.id });
expect(dialog).toMatchSnapshot();
});

it('sets the recommended Ids (with debounced delay) when a change in dx (Data) or ou (Organisation Unit) occurs', () => {
const dialog = dialogManager();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,87 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`The DialogManager component renders OUDimension content with display:none when previously mounted 1`] = `
<Component
data-test="dialog-manager"
disableEnforceFocus={true}
keepMounted={true}
maxWidth="lg"
onClose={[Function]}
open={false}
>
<div
key="ou"
style={
Object {
"display": "block",
}
}
>
<Connect(OrgUnitDimension) />
</div>
<Component>
<Connect(HideButton) />
<Connect(WithStyles(AddToLayoutButton))
dialogId="ou"
/>
</Component>
</Component>
`;

exports[`The DialogManager component renders OUDimension content with display:none when previously mounted 2`] = `
<Component
data-test="dialog-manager"
disableEnforceFocus={true}
keepMounted={true}
maxWidth="lg"
onClose={[Function]}
open={false}
>
<div
key="ou"
style={
Object {
"display": "none",
}
}
>
<Connect(OrgUnitDimension) />
</div>
<Component>
<Connect(HideButton) />
</Component>
</Component>
`;

exports[`The DialogManager component renders OUDimension content with display:none when previously mounted 3`] = `
<Component
data-test="dialog-manager"
disableEnforceFocus={true}
keepMounted={false}
maxWidth="lg"
onClose={[Function]}
open={false}
>
<div
key="ou"
style={
Object {
"display": "none",
}
}
>
<Connect(OrgUnitDimension) />
</div>
<Connect(DataDimension) />
<Component>
<Connect(HideButton) />
<Connect(WithStyles(AddToLayoutButton))
dialogId="dx"
/>
</Component>
</Component>
`;

exports[`The DialogManager component renders a closed dialog 1`] = `
<Component
data-test="dialog-manager"
Expand All @@ -15,6 +97,25 @@ exports[`The DialogManager component renders a closed dialog 1`] = `
</Component>
`;

exports[`The DialogManager component renders the DataDimension content in dialog 1`] = `
<Component
data-test="dialog-manager"
disableEnforceFocus={true}
keepMounted={false}
maxWidth="lg"
onClose={[Function]}
open={false}
>
<Connect(DataDimension) />
<Component>
<Connect(HideButton) />
<Connect(WithStyles(AddToLayoutButton))
dialogId="dx"
/>
</Component>
</Component>
`;

exports[`The DialogManager component renders the DynamicDimension content in dialog 1`] = `
<Component
data-test="dialog-manager"
Expand All @@ -35,3 +136,50 @@ exports[`The DialogManager component renders the DynamicDimension content in dia
</Component>
</Component>
`;

exports[`The DialogManager component renders the OrgUnitDimension content in dialog 1`] = `
<Component
data-test="dialog-manager"
disableEnforceFocus={true}
keepMounted={true}
maxWidth="lg"
onClose={[Function]}
open={false}
>
<div
key="ou"
style={
Object {
"display": "block",
}
}
>
<Connect(OrgUnitDimension) />
</div>
<Component>
<Connect(HideButton) />
<Connect(WithStyles(AddToLayoutButton))
dialogId="ou"
/>
</Component>
</Component>
`;

exports[`The DialogManager component renders the PeriodDimension content in dialog 1`] = `
<Component
data-test="dialog-manager"
disableEnforceFocus={true}
keepMounted={false}
maxWidth="lg"
onClose={[Function]}
open={false}
>
<Connect(PeriodDimension) />
<Component>
<Connect(HideButton) />
<Connect(WithStyles(AddToLayoutButton))
dialogId="pe"
/>
</Component>
</Component>
`;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { shallow, mount } from 'enzyme';
import { mount } from 'enzyme';
import { SelectedItems } from '../SelectedItems';

describe('The SelectedItems component', () => {
Expand All @@ -22,10 +22,6 @@ describe('The SelectedItems component', () => {
selectedItemsWrapper = undefined;
});

// it('matches the snapshot when list is empty', () => {
// expect(selectedItems()).toMatchSnapshot();
// });

describe('list with items', () => {
beforeEach(() => {
props.items = [
Expand All @@ -36,9 +32,6 @@ describe('The SelectedItems component', () => {
{ id: 'rr', name: 'rarity' },
];
});
// it('matches the snapshot with list has items', () => {
// expect(selectedItems()).toMatchSnapshot();
// });

it('triggers onDeselect when item double-clicked', () => {
selectedItems()
Expand Down

0 comments on commit 870486d

Please sign in to comment.