102 lines
2.7 KiB
JavaScript
102 lines
2.7 KiB
JavaScript
|
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);
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|