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,75 @@
import {BaseService, ServiceState} from '@bthlabs/homehub-core';
import {shallow} from 'enzyme';
import React from 'react';
import {FatalError} from 'src/FatalError';
class FakeService extends BaseService {
static kind = 'FakeService';
static widget = 'FakeWidget';
}
describe('src/FatalError', () => {
let service = null;
let serviceState = null;
beforeEach(() => {
service = new FakeService({
instance: 'testing',
characteristics: {},
});
serviceState = new ServiceState({
error: {
message: 'FIAL',
},
});
});
it('allows passing an arbitrary class name', () => {
// Given
const component = shallow(
<FatalError
className="test"
service={service}
serviceState={serviceState}
/>
);
// Then
expect(component.hasClass('test')).toBe(true);
});
it('renders the service kind and instance', () => {
// Given
const component = shallow(
<FatalError
className="test"
service={service}
serviceState={serviceState}
/>
);
// When
const code = component.find('code').at(0);
// Then
expect(code.text()).toEqual(`${service.kind}:${service.instance}`);
});
it('renders the error message', () => {
// Given
const component = shallow(
<FatalError
className="test"
service={service}
serviceState={serviceState}
/>
);
// When
const code = component.find('code').at(1);
// Then
expect(code.text()).toEqual(serviceState.error().message);
});
});

View File

@@ -0,0 +1,49 @@
import {shallow} from 'enzyme';
import React from 'react';
import {Widget} from 'src/Widget';
describe('src/Widget', () => {
it('allows passing an arbitrary class name', () => {
// Given
const component = shallow(
<Widget className="test">
<span>It works!</span>
</Widget>
);
// Then
expect(component.hasClass('test')).toBe(true);
});
it('uses the appearance to change the style', () => {
// Given
const component = shallow(
<Widget appearance={{color: 'red'}}>
<span>It works!</span>
</Widget>
);
// When
const style = component.prop('style');
// Then
expect(style.backgroundColor).toEqual('red');
});
it('renders the children', () => {
// Given
const component = shallow(
<Widget>
<span>It works!</span>
</Widget>
);
// When
const span = component.find('span').at(0);
// Then
expect(span.exists()).toBe(true);
expect(span.text()).toEqual('It works!');
});
});

View File

@@ -0,0 +1,4 @@
require('tests/__setup__/enzyme.setup.js');
let testsContext = require.context('.', true, /\.spec\.js$/);
testsContext.keys().forEach(testsContext);

View File

@@ -0,0 +1,7 @@
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({
adapter: new Adapter(),
disableLifecycleMethods: true,
});