OpenMediaCenter/src/App.test.js

44 lines
1.1 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';
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
it('test initial fetch from api', done => {
global.fetch = global.prepareFetchApi({
generalSettingsLoaded: true,
passwordsupport: true,
mediacentername: 'testname'
});
const wrapper = shallow(<App/>);
2020-07-16 19:13:54 +02:00
const func = jest.fn();
wrapper.instance().setState = func;
expect(global.fetch).toBeCalledTimes(1);
process.nextTick(() => {
2020-07-16 19:13:54 +02:00
expect(func).toBeCalledTimes(1);
global.fetch.mockClear();
done();
});
});
2020-06-09 20:10:26 +02:00
});