Merge pull request #156 from renjithgr/main

[GH-132] - Add snapshot test for propertyMenu component
This commit is contained in:
Jesús Espino 2021-03-21 08:59:42 +01:00 committed by GitHub
commit 3d904eebf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 243 additions and 0 deletions

View file

@ -0,0 +1,225 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`widgets/PropertyMenu should match snapshot 1`] = `
<div>
<div
class="Menu noselect bottom"
>
<div
class="menu-contents"
>
<div
class="menu-options"
>
<input
class="PropertyMenu menu-textbox"
type="text"
value="test-property"
/>
<div
class="MenuOption SubMenuOption menu-option"
>
<div
class="noicon"
/>
<div
class="menu-name"
>
Type: Text
</div>
<svg
class="SubmenuTriangleIcon Icon"
viewBox="0 0 100 100"
xmlns="http://www.w3.org/2000/svg"
>
<polygon
points="50,35 75,50 50,65"
/>
</svg>
<div
class="SubMenu Menu noselect bottom"
>
<div
class="menu-contents"
>
<div
class="menu-options"
>
<div
class="MenuOption LabelOption menu-option"
>
<div
class="noicon"
/>
<div
class="menu-name"
>
<b>
Change property type
</b>
</div>
<div
class="noicon"
/>
</div>
<div
class="MenuOption MenuSeparator menu-separator"
/>
<div
class="MenuOption TextOption menu-option"
>
<div
class="noicon"
/>
<div
class="menu-name"
>
Text
</div>
<div
class="noicon"
/>
</div>
<div
class="MenuOption TextOption menu-option"
>
<div
class="noicon"
/>
<div
class="menu-name"
>
Number
</div>
<div
class="noicon"
/>
</div>
<div
class="MenuOption TextOption menu-option"
>
<div
class="noicon"
/>
<div
class="menu-name"
>
Email
</div>
<div
class="noicon"
/>
</div>
<div
class="MenuOption TextOption menu-option"
>
<div
class="noicon"
/>
<div
class="menu-name"
>
Select
</div>
<div
class="noicon"
/>
</div>
<div
class="MenuOption TextOption menu-option"
>
<div
class="noicon"
/>
<div
class="menu-name"
>
Created Time
</div>
<div
class="noicon"
/>
</div>
<div
class="MenuOption TextOption menu-option"
>
<div
class="noicon"
/>
<div
class="menu-name"
>
Updated Time
</div>
<div
class="noicon"
/>
</div>
</div>
<div
class="menu-spacer hideOnWidescreen"
/>
<div
class="menu-options hideOnWidescreen"
>
<div
class="MenuOption TextOption menu-option menu-cancel"
>
<div
class="noicon"
/>
<div
class="menu-name"
>
Cancel
</div>
<div
class="noicon"
/>
</div>
</div>
</div>
</div>
</div>
<div
class="MenuOption TextOption menu-option"
>
<div
class="noicon"
/>
<div
class="menu-name"
>
Delete
</div>
<div
class="noicon"
/>
</div>
</div>
<div
class="menu-spacer hideOnWidescreen"
/>
<div
class="menu-options hideOnWidescreen"
>
<div
class="MenuOption TextOption menu-option menu-cancel"
>
<div
class="noicon"
/>
<div
class="menu-name"
>
Cancel
</div>
<div
class="noicon"
/>
</div>
</div>
</div>
</div>
</div>
`;

View file

@ -87,4 +87,22 @@ describe('widgets/PropertyMenu', () => {
fireEvent.click(getByText('Select')) fireEvent.click(getByText('Select'))
expect(callback).toHaveBeenCalledWith('select') expect(callback).toHaveBeenCalledWith('select')
}) })
test('should match snapshot', () => {
const callback = jest.fn()
const component = wrapIntl(
<PropertyMenu
propertyId={'id'}
propertyName={'test-property'}
propertyType={'text'}
onTypeChanged={callback}
onNameChanged={callback}
onDelete={callback}
/>,
)
const {container, getByText} = render(component)
const menuOpen = getByText(/Type: Text/i)
fireEvent.click(menuOpen)
expect(container).toMatchSnapshot()
})
}) })