Release 1.3.0

This commit is contained in:
2021-08-26 12:33:15 +02:00
commit 9bb72f0207
1148 changed files with 92133 additions and 0 deletions

View File

@@ -0,0 +1,101 @@
import {DashboardsProvider} from '@bthlabs/homehub-core';
import {shallow} from 'enzyme';
import React from 'react';
import {DashboardContainer, TaskbarContainer} from 'src/main/containers';
import {StateDataSource} from 'src/main/dataSources';
import * as AppView from 'src/main/views/AppView';
import {SettingsFactory} from 'tests/__fixtures__/settings';
describe('src/main/views/AppView', () => {
describe('AppView', () => {
let fakeActions = null;
let fakeSetings = null;
beforeEach(() => {
fakeActions = {
setDocumentTitle: jasmine.createSpy(),
};
fakeSetings = SettingsFactory();
});
describe('componentDidMount', () => {
it('calls the setDocumentTitle action', () => {
// Given
const component = shallow(
<AppView.AppView
actions={fakeActions}
settings={fakeSetings}
/>
);
// When
component.instance().componentDidMount();
// Then
expect(fakeActions.setDocumentTitle).toHaveBeenCalledWith(
jasmine.any(String)
);
});
});
describe('render', () => {
it('configures and renders the DashboardsProvider', () => {
// Given
const component = shallow(
<AppView.AppView
actions={fakeActions}
settings={fakeSetings}
/>
);
// When
const dashboardsProvider = component.find(DashboardsProvider).at(0);
// Then
expect(dashboardsProvider.exists()).toBe(true);
expect(dashboardsProvider.prop('loader')).toBeDefined();
expect(dashboardsProvider.prop('loadDashboards')).toEqual(
StateDataSource.loadState
);
expect(dashboardsProvider.prop('saveDashboards')).toEqual(
StateDataSource.saveState
);
expect(dashboardsProvider.prop('settings')).toEqual(fakeSetings);
});
it('configures and renders the DashboardContainer', () => {
// Given
const component = shallow(
<AppView.AppView
actions={fakeActions}
settings={fakeSetings}
/>
);
// When
const dashboardContainer = component.find(DashboardContainer).at(0);
// Then
expect(dashboardContainer.exists()).toBe(true);
});
it('configures and renders the TaskbarContainer', () => {
// Given
const component = shallow(
<AppView.AppView
actions={fakeActions}
settings={fakeSetings}
/>
);
// When
const taskbarContainer = component.find(TaskbarContainer).at(0);
// Then
expect(taskbarContainer.exists()).toBe(true);
});
});
});
});

View File

@@ -0,0 +1,86 @@
import {shallow} from 'enzyme';
import React from 'react';
import * as ErrorBoundaryView from 'src/main/views/ErrorBoundaryView';
describe('src/main/views/ErrorBoundaryView', () => {
describe('ErrorBoundaryView', () => {
let fakeError = null;
beforeEach(() => {
fakeError = new Error('FIAL');
});
describe('constructor', () => {
it('initializes the state', () => {
// Given
const component = shallow(
<ErrorBoundaryView.ErrorBoundaryView>
<span>It works!</span>
</ErrorBoundaryView.ErrorBoundaryView>
);
// Then
expect(component.state('error')).toBe(null);
});
});
describe('componentDidCatch', () => {
it('updates the state with error', () => {
// Given
const component = shallow(
<ErrorBoundaryView.ErrorBoundaryView>
<span>It works!</span>
</ErrorBoundaryView.ErrorBoundaryView>
);
// When
component.instance().componentDidCatch(fakeError);
// Then
expect(component.state('error')).toEqual(fakeError);
});
});
describe('render', () => {
let fakeChildren = null;
beforeEach(() => {
fakeChildren = <span>It works!</span>;
});
it('renders the children when error is null', () => {
// Given
const component = shallow(
<ErrorBoundaryView.ErrorBoundaryView>
{fakeChildren}
</ErrorBoundaryView.ErrorBoundaryView>
);
// When
component.setState({error: null});
// Then
expect(component.contains(fakeChildren)).toBe(true);
expect(component.contains('.ErrorBoundaryView')).toBe(false);
});
it('renders the error view when error is not null', () => {
// Given
const component = shallow(
<ErrorBoundaryView.ErrorBoundaryView>
{fakeChildren}
</ErrorBoundaryView.ErrorBoundaryView>
);
// When
component.setState({error: fakeError});
// Then
expect(component.contains(fakeChildren)).toBe(false);
expect(component.hasClass('ErrorBoundaryView')).toBe(true);
expect(component.find('p').at(1).text()).toMatch(fakeError.message);
});
});
});
});