-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
2,117 additions
and
123 deletions.
There are no files selected for viewing
1,339 changes: 1,280 additions & 59 deletions
1,339
...olution-exception-list-components/src/list_header/__snapshots__/list_header.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
227 changes: 227 additions & 0 deletions
227
...ception-list-components/src/list_header/edit_modal/__snapshots__/edit_modal.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
...securitysolution-exception-list-components/src/list_header/edit_modal/edit_modal.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import React from 'react'; | ||
import { fireEvent, render } from '@testing-library/react'; | ||
import { EditModal } from '.'; | ||
|
||
const onSave = jest.fn(); | ||
const onCancel = jest.fn(); | ||
|
||
describe('EditModal', () => { | ||
it('should render the title and description from listDetails', () => { | ||
const wrapper = render( | ||
<EditModal | ||
listDetails={{ name: 'list name', description: 'list description' }} | ||
onSave={onSave} | ||
onCancel={onCancel} | ||
/> | ||
); | ||
expect(wrapper).toMatchSnapshot(); | ||
expect(wrapper.getByTestId('editModalTitle')).toHaveTextContent('list name'); | ||
}); | ||
it('should call onSave', () => { | ||
const wrapper = render( | ||
<EditModal | ||
listDetails={{ name: 'list name', description: 'list description' }} | ||
onSave={onSave} | ||
onCancel={onCancel} | ||
/> | ||
); | ||
fireEvent.submit(wrapper.getByTestId('editModalForm')); | ||
expect(onSave).toBeCalled(); | ||
}); | ||
it('should call onCancel', () => { | ||
const wrapper = render( | ||
<EditModal | ||
listDetails={{ name: 'list name', description: 'list description' }} | ||
onSave={onSave} | ||
onCancel={onCancel} | ||
/> | ||
); | ||
fireEvent.click(wrapper.getByTestId('editModalCancelBtn')); | ||
expect(onCancel).toBeCalled(); | ||
}); | ||
|
||
it('should call change title, description and call onSave with the new props', () => { | ||
const wrapper = render( | ||
<EditModal | ||
listDetails={{ name: 'list name', description: 'list description' }} | ||
onSave={onSave} | ||
onCancel={onCancel} | ||
/> | ||
); | ||
fireEvent.change(wrapper.getByTestId('editModalNameTextField'), { | ||
target: { value: 'New list name' }, | ||
}); | ||
fireEvent.change(wrapper.getByTestId('editModalDescriptionTextField'), { | ||
target: { value: 'New description name' }, | ||
}); | ||
fireEvent.submit(wrapper.getByTestId('editModalForm')); | ||
|
||
expect(onSave).toBeCalledWith({ | ||
name: 'New list name', | ||
description: 'New description name', | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.