-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: zhichao-aws <[email protected]>
- Loading branch information
1 parent
e07519b
commit 165cd0d
Showing
15 changed files
with
396 additions
and
4 deletions.
There are no files selected for viewing
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,11 @@ | ||
{ | ||
"config": { | ||
"name": "Test microsoft teams channel", | ||
"description": "A test microsoft teams channel", | ||
"config_type": "microsoft_teams", | ||
"is_enabled": true, | ||
"microsoft_teams": { | ||
"url": "https://testdomain.webhook.office.com/123" | ||
} | ||
} | ||
} |
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
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
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
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
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
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
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
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
77 changes: 77 additions & 0 deletions
77
public/pages/CreateChannel/__tests__/MicrosoftTeamsSettings.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,77 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { fireEvent, render } from '@testing-library/react'; | ||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import React from 'react'; | ||
import { MicrosoftTeamsSettings } from '../components/MicrosoftTeamsSettings'; | ||
import { CreateChannelContext } from '../CreateChannel'; | ||
|
||
describe('<MicrosoftTeamsSettings /> spec', () => { | ||
configure({ adapter: new Adapter() }); | ||
|
||
it('renders the component', () => { | ||
const setMicrosoftTeamsWebhook = jest.fn(); | ||
const utils = render( | ||
<CreateChannelContext.Provider | ||
value={{ | ||
edit: false, | ||
inputErrors: { microsoftTeamsWebhook: [] }, | ||
setInputErrors: jest.fn(), | ||
}} | ||
> | ||
<MicrosoftTeamsSettings | ||
microsoftTeamsWebhook="test webhook" | ||
setMicrosoftTeamsWebhook={setMicrosoftTeamsWebhook} | ||
/> | ||
</CreateChannelContext.Provider> | ||
); | ||
expect(utils.container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders the component with error', () => { | ||
const setMicrosoftTeamsWebhook = jest.fn(); | ||
const utils = render( | ||
<CreateChannelContext.Provider | ||
value={{ | ||
edit: false, | ||
inputErrors: { microsoftTeamsWebhook: ['test error'] }, | ||
setInputErrors: jest.fn(), | ||
}} | ||
> | ||
<MicrosoftTeamsSettings | ||
microsoftTeamsWebhook="test webhook" | ||
setMicrosoftTeamsWebhook={setMicrosoftTeamsWebhook} | ||
/> | ||
</CreateChannelContext.Provider> | ||
); | ||
expect(utils.container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
it('changes input', () => { | ||
const setMicrosoftTeamsWebhook = jest.fn(); | ||
const setInputErrors = jest.fn(); | ||
const utils = render( | ||
<CreateChannelContext.Provider | ||
value={{ | ||
edit: false, | ||
inputErrors: { microsoftTeamsWebhook: [] }, | ||
setInputErrors, | ||
}} | ||
> | ||
<MicrosoftTeamsSettings | ||
microsoftTeamsWebhook="test webhook" | ||
setMicrosoftTeamsWebhook={setMicrosoftTeamsWebhook} | ||
/> | ||
</CreateChannelContext.Provider> | ||
); | ||
const input = utils.getByLabelText('Webhook URL'); | ||
fireEvent.change(input, { target: { value: 'https://test-microsoftTeams-url' } }); | ||
fireEvent.blur(input); | ||
expect(setMicrosoftTeamsWebhook).toBeCalledWith('https://test-microsoftTeams-url'); | ||
expect(setInputErrors).toBeCalled(); | ||
}); | ||
}); |
Oops, something went wrong.