Skip to content

Instantly share code, notes, and snippets.

@adrian-afergon
Created April 11, 2019 19:37
Show Gist options
  • Save adrian-afergon/d9f32c2311c8ebb334fcf886f4cc17d6 to your computer and use it in GitHub Desktop.
Save adrian-afergon/d9f32c2311c8ebb334fcf886f4cc17d6 to your computer and use it in GitHub Desktop.
This is an example of a not readable test
import { shallow } from 'enzyme';
import * as React from 'react';
import { ExerciseDetail } from './';
describe('ExerciseDetail', () => {
it('should display the warning', () => {
const anExercise: Exercise = {
warning: 'irrelevant warning message',
tags: ['irrelevant tag', 'irrelevant tag'],
name: 'irrelevant name',
image: 'irrelevant image url'
// ... at less 20 props
}
const wrapper = shallow(<ExerciseDetail exercise={anExercise}/>);
const message = wrapper.find('Message');
expect(message.exists()).toBeTruthy();
});
it('should not display the warning', () => {
const anExercise: Exercise = {
warning: 'irrelevant warning message',
tags: ['irrelevant tag', 'irrelevant tag'],
name: 'irrelevant name',
image: 'irrelevant image url'
// ... at less 20 props
}
const wrapper = shallow(<ExerciseDetail exercise={anExercise}/>);
const message = wrapper.find('Message');
expect(message.exists()).toBeFalsy();
});
it('should render a list of 2 tags', () => {
const anExercise: Exercise = {
warning: 'irrelevant warning message',
tags: ['irrelevant tag', 'irrelevant tag'],
name: 'irrelevant name',
image: 'irrelevant image url'
// ... at less 20 props
}
const wrapper = shallow(<ExerciseDetail exercise={anExercise}/>);
const chips = wrapper.find('Chip');
expect(chips.length).toBe(2);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment