Created
April 11, 2019 20:42
-
-
Save adrian-afergon/a43f715ad232b6253ea5715d20b57337 to your computer and use it in GitHub Desktop.
Create an exercise warning wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { shallow } from 'enzyme'; | |
import * as React from 'react'; | |
import { ExerciseDetail } from './'; | |
import { createAnExercise } from './ExerciseMockBuilder' | |
describe('ExerciseDetail', () => { | |
it('should display the warning when it\'s present in the exercise', () => { | |
const anExercise: Exercise = createAnExercise({warning: 'a warning message'}) | |
const message = createAnExerciseWarningWrapper(anExercise); | |
expect(message.exists()).toBeTruthy(); | |
}); | |
it('should not display the warning when it\'s not set in the exercise', () => { | |
const anExercise: Exercise = createAnExercise({warning: null}) | |
const message = createAnExerciseWarningWrapper(anExercise); | |
expect(message.exists()).toBeFalsy(); | |
}); | |
it('should render a list multiple tags', () => { | |
const someTags = ['irrelevant tag 1', 'irrelevant tag 2'] | |
const anExercise: Exercise = createAnExercise({tags: someTags}) | |
const wrapper = shallow(<ExerciseDetail exercise={anExercise}/>); | |
const chips = wrapper.find('Chip'); | |
expect(chips.length).toBe(someTags.length); | |
}); | |
}); | |
const createAnExerciseWarningWrapper = (anExercise: Exercise) => { | |
const wrapper = shallow(<ExerciseDetail exercise={anExercise}/>); | |
return wrapper.find('Message'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment