2020-06-09 20:10:26 +02:00
|
|
|
import React from 'react';
|
|
|
|
import App from './App';
|
2020-10-25 18:48:23 +00:00
|
|
|
import {shallow} from 'enzyme';
|
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/>);
|
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/>);
|
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
|
|
|
|
2020-07-15 20:08:22 +02:00
|
|
|
it('test initial fetch from api', done => {
|
2020-08-05 17:55:51 +00:00
|
|
|
global.fetch = global.prepareFetchApi({
|
2020-07-15 20:08:22 +02:00
|
|
|
generalSettingsLoaded: true,
|
|
|
|
passwordsupport: true,
|
2020-10-25 18:48:23 +00:00
|
|
|
mediacentername: 'testname'
|
2020-07-15 20:08:22 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
const wrapper = shallow(<App/>);
|
|
|
|
|
2020-07-16 19:13:54 +02:00
|
|
|
|
|
|
|
const func = jest.fn();
|
|
|
|
wrapper.instance().setState = func;
|
|
|
|
|
2020-07-15 20:08:22 +02:00
|
|
|
expect(global.fetch).toBeCalledTimes(1);
|
|
|
|
|
|
|
|
process.nextTick(() => {
|
2020-07-16 19:13:54 +02:00
|
|
|
expect(func).toBeCalledTimes(1);
|
2020-07-15 20:08:22 +02:00
|
|
|
|
|
|
|
global.fetch.mockClear();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2020-06-09 20:10:26 +02:00
|
|
|
});
|