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(
);
// Then
expect(component.hasClass('test')).toBe(true);
});
it('renders the service kind and instance', () => {
// Given
const component = shallow(
);
// 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(
);
// When
const code = component.find('code').at(1);
// Then
expect(code.text()).toEqual(serviceState.error().message);
});
});