OpenMediaCenter/src/App.test.js

48 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-06-09 20:10:26 +02:00
import React from 'react';
import App from './App';
import {shallow} from 'enzyme';
import GlobalInfos from "./utils/GlobalInfos";
2020-06-09 20:10:26 +02:00
describe('<App/>', function () {
2020-06-12 15:57:30 +00:00
it('renders without crashing ', function () {
const wrapper = shallow(<App/>);
wrapper.unmount();
});
2020-06-09 20:10:26 +02:00
2020-06-12 15:57:30 +00:00
it('renders title', () => {
const wrapper = shallow(<App/>);
wrapper.setState({password: false});
2020-08-02 17:55:06 +00:00
expect(wrapper.find('.navbrand').text()).toBe('OpenMediaCenter');
2020-06-12 15:57:30 +00:00
});
2020-06-09 20:10:26 +02:00
2020-06-12 15:57:30 +00:00
it('are navlinks correct', function () {
const wrapper = shallow(<App/>);
wrapper.setState({password: false});
2020-08-02 17:55:06 +00:00
expect(wrapper.find('.navitem')).toHaveLength(4);
2020-06-12 15:57:30 +00:00
});
2020-06-18 19:42:42 +02:00
it('test initial fetch from api', done => {
callAPIMock({
MediacenterName: 'testname'
})
GlobalInfos.enableDarkTheme = jest.fn((r) => {})
2020-07-16 19:13:54 +02:00
const wrapper = shallow(<App/>);
process.nextTick(() => {
expect(document.title).toBe('testname');
global.fetch.mockClear();
done();
});
});
it('test render of password page', function () {
const wrapper = shallow(<App/>);
wrapper.setState({password: true});
expect(wrapper.find('AuthenticationPage')).toHaveLength(1);
});
2020-06-09 20:10:26 +02:00
});