Created
May 27, 2016 16:44
-
-
Save kevinsalter/656c37aff7335b41dd9bcbd342d5ab73 to your computer and use it in GitHub Desktop.
<Loading /> unit tests
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 {assert} from 'chai'; | |
import Loading from '../src/loading.js'; | |
describe('<Loading />', () => { | |
const LOADING_PROPS = { | |
imgSrc: 'https://media.giphy.com/media/feN0YJbVs0fwA/giphy.gif' | |
}; | |
const wrapper = shallow(<Loading {...LOADING_PROPS} />); | |
it('should be wrapped in a div', () => { | |
const loadingImageContainer = wrapper.find('div.loading-image-centered'); | |
assert.equal(loadingImageContainer.length, 1); | |
assert.ok(loadingImageContainer.hasClass('loading-image-centered')); | |
}); | |
it('should have a loading image with the correct defaults set', () => { | |
const loadingImage = wrapper.find('img'); | |
assert.equal(loadingImage.length, 1); | |
assert.equal(loadingImage.prop('src'), LOADING_PROPS.imgSrc); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment