You've already forked homehub
Release 1.3.0
This commit is contained in:
4
packages/homehub_icons/tests/__entry__.js
Normal file
4
packages/homehub_icons/tests/__entry__.js
Normal file
@@ -0,0 +1,4 @@
|
||||
require('tests/__setup__/enzyme.setup.js');
|
||||
|
||||
let testsContext = require.context('.', true, /\.spec\.js$/);
|
||||
testsContext.keys().forEach(testsContext);
|
||||
7
packages/homehub_icons/tests/__setup__/enzyme.setup.js
Normal file
7
packages/homehub_icons/tests/__setup__/enzyme.setup.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import Enzyme from 'enzyme';
|
||||
import Adapter from 'enzyme-adapter-react-16';
|
||||
|
||||
Enzyme.configure({
|
||||
adapter: new Adapter(),
|
||||
disableLifecycleMethods: true,
|
||||
});
|
||||
60
packages/homehub_icons/tests/components/Icon.spec.js
Normal file
60
packages/homehub_icons/tests/components/Icon.spec.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import {shallow} from 'enzyme';
|
||||
import React from 'react';
|
||||
|
||||
import {Icon} from 'src/components/Icon';
|
||||
|
||||
describe('src/components/Icon', () => {
|
||||
const FakeIcon = (props) => { // eslint-disable-line no-unused-vars
|
||||
return <span>It works!</span>;
|
||||
};
|
||||
|
||||
it('allows passing an arbitrary class name', () => {
|
||||
const component = shallow(
|
||||
<Icon className="test" icon={FakeIcon} />
|
||||
);
|
||||
expect(component.hasClass('test')).toBe(true);
|
||||
});
|
||||
|
||||
it('allows specifying the size', () => {
|
||||
const component = shallow(
|
||||
<Icon icon={FakeIcon} size="16px" />
|
||||
);
|
||||
|
||||
const style = component.prop('style');
|
||||
expect(style.height).toEqual('16px');
|
||||
expect(style.width).toEqual('16px');
|
||||
});
|
||||
|
||||
it('defaults size to 1em if not specified', () => {
|
||||
const component = shallow(
|
||||
<Icon icon={FakeIcon} />
|
||||
);
|
||||
|
||||
const style = component.prop('style');
|
||||
expect(style.height).toEqual('1em');
|
||||
expect(style.width).toEqual('1em');
|
||||
});
|
||||
|
||||
it('allows setting vertical align to middle', () => {
|
||||
const component = shallow(
|
||||
<Icon icon={FakeIcon} middle />
|
||||
);
|
||||
|
||||
const style = component.prop('style');
|
||||
expect(style.verticalAlign).toEqual('middle');
|
||||
});
|
||||
|
||||
it('allows specifying a title', () => {
|
||||
const component = shallow(
|
||||
<Icon icon={FakeIcon} title="Test" />
|
||||
);
|
||||
expect(component.prop('title')).toEqual('Test');
|
||||
});
|
||||
|
||||
it('renders the element passed in the icon prop', () => {
|
||||
const component = shallow(
|
||||
<Icon icon={FakeIcon} />
|
||||
);
|
||||
expect(component.find(FakeIcon).exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user