1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 06:00:06 +02:00

add simple tests to more components

This commit is contained in:
Sérgio Ramos 2016-10-28 16:49:00 +01:00
parent 3243941056
commit d108a14ff4
2 changed files with 48 additions and 24 deletions

View File

@ -7,7 +7,7 @@ const styles = require('./style.css');
const Avatar = ({
color,
src,
name,
name = '',
className,
style
}) => {
@ -22,32 +22,26 @@ const Avatar = ({
background: color
};
const fill = () => {
if ( src ) {
return (
<img
alt={name}
className={styles.picture}
src={src}
style={style}
/>
);
} else {
const letter = name.split('')[0];
return (
<p
className={styles.letter}
style={style}
>
{letter}
</p>
);
}
};
const letter = name.split('')[0];
const av = src ? (
<img
alt={name}
className={styles.picture}
src={src}
style={style}
/>
) : (
<p
className={styles.letter}
style={style}
>
{letter}
</p>
);
return (
<div className={cn} style={style}>
{fill()}
{av}
</div>
);
};

View File

@ -6,8 +6,38 @@ const {
shallow
} = enzyme;
test('renders <Avatar> without exploding', (t) => {
const Avatar = require('../src/components/avatar');
const wrapper = shallow(<Avatar />);
t.deepEqual(wrapper.length, 1);
});
test('renders <Base> without exploding', (t) => {
const Base = require('../src/components/base');
const wrapper = shallow(<Base />);
t.deepEqual(wrapper.length, 1);
});
test('renders <Button> without exploding', (t) => {
const Button = require('../src/components/button');
const wrapper = shallow(<Button />);
t.deepEqual(wrapper.length, 1);
});
test('renders <Checkbox> without exploding', (t) => {
const Checkbox = require('../src/components/checkbox');
const wrapper = shallow(<Checkbox />);
t.deepEqual(wrapper.length, 1);
});
test('renders <Column> without exploding', (t) => {
const Column = require('../src/components/column');
const wrapper = shallow(<Column />);
t.deepEqual(wrapper.length, 1);
});
test('renders <Container> without exploding', (t) => {
const Container = require('../src/components/container');
const wrapper = shallow(<Container />);
t.deepEqual(wrapper.length, 1);
});