Created
March 22, 2018 23:29
-
-
Save Nfinley/89bc208cd2db5b745161db4bd7cdbc31 to your computer and use it in GitHub Desktop.
A jest snippet to test a component
This file contains 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 React from 'react'; | |
import {shallow} from 'enzyme'; | |
import $ComponentName$ from '$filepath$' | |
describe('$ComponentName$ Test', () => { | |
const props = {}; | |
const wrapper = shallow(<$ComponentName$ {...props}/>); | |
describe('$ComponentName$ State Test', () => { | |
it('Should have the correct state', () => { | |
// Test state here | |
}); | |
}); | |
describe('$ComponentName$ Props Test', () => { | |
it('Should have the correct set of Props', () => { | |
// Test Props Here | |
}); | |
}); | |
describe('$ComponentName$ Actions Test', () => { | |
it('Should have the correct set of actions', () => { | |
// Test Actions Here | |
}); | |
}); | |
describe('$ComponentName$ Elements Test', () => { | |
it('Should contain two elements', () => { | |
expect(wrapper.find('element').length).toEqual(2); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment