Commit dec8c6a3 authored by Bogdan Bodnar's avatar Bogdan Bodnar

Test notifications email settings.

parent 5019c0c9
/*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
*/
import React from 'react';
import {act, render, getByLabelText, fireEvent} from 'react-testing-library';
import mockFetch from '../../testUtils/mockFetch';
import {mockedWS} from '../../testUtils/mockWS';
import NotificationsEmailSettings from '../NotificationsCenter/NotificationsEmailSettings/NotificationsEmailSettings';
import {notificationsEmailSettingsFixure} from './__fixtures__/notificationsEmailSettings';
describe('<NotificationsDropdown/>', () => {
let NotificationCenterContainer;
beforeEach(() => {
const mockWebSockets = new mockedWS();
global.fetch = mockFetch(notificationsEmailSettingsFixure());
const {container} = render(<NotificationsEmailSettings ws={mockWebSockets}/>);
NotificationCenterContainer = container
});
it('Enabled, smtp_type:custom', () => {
expect(NotificationCenterContainer.firstChild).toMatchSnapshot()
});
it('Disabled', () => {
act(() => {
fireEvent.click(getByLabelText(NotificationCenterContainer, 'Enable email notifications'));
});
expect(NotificationCenterContainer.firstChild).toMatchSnapshot()
});
it('Enabled,smtp_type:turris', () => {
act(() => {
fireEvent.click(getByLabelText(NotificationCenterContainer, 'Turris'));
});
expect(NotificationCenterContainer.firstChild).toMatchSnapshot()
})
});
\ No newline at end of file
......@@ -5,11 +5,12 @@
* See /LICENSE for more information.
*/
import React from 'react';
import {render, waitForElement, getByText} from 'react-testing-library';
import {render, waitForElement, getByText, act} from 'react-testing-library';
import {mockedWS} from '../../testUtils/mockWS';
import {notificationsEmailSettingsFixure, notificationsFixture} from './__fixtures__/notifications';
import {notificationsFixture} from './__fixtures__/notifications';
import NotificationsCenter from '../NotificationsCenter/NotificationsCenter';
import {notificationsEmailSettingsFixure} from './__fixtures__/notificationsEmailSettings';
function mockFetch() {
return jest.fn((url) => {
......
......@@ -29,34 +29,3 @@ export function notificationsFixture() {
}
}
export function notificationsEmailSettingsFixure() {
return {
emails: {
common: {
"send_news": true,
"severity_filter": 1,
"to": [
"some@example.com"
]
},
"enabled": true,
"smtp_custom": {
"from": "router@example.com",
"host": "example.com",
"password": "test_password",
"port": 465,
"security": "ssl",
"username": "root"
},
"smtp_turris": {
"sender_name": "turris"
},
"smtp_type": "custom"
},
"reboots": {
"delay": 3,
"time": "03:30"
}
}
}
\ No newline at end of file
/*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
*/
export function notificationsEmailSettingsFixure() {
return {
emails: {
common: {
"send_news": true,
"severity_filter": 1,
"to": [
"some@example.com"
]
},
"enabled": true,
"smtp_custom": {
"from": "router@example.com",
"host": "example.com",
"password": "test_password",
"port": 465,
"security": "ssl",
"username": "root"
},
"smtp_turris": {
"sender_name": "turris"
},
"smtp_type": "custom"
},
"reboots": {
"delay": 3,
"time": "03:30"
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment