Skip to content

Instantly share code, notes, and snippets.

@busypeoples
Created March 8, 2016 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save busypeoples/26595bb9713c1844fcb1 to your computer and use it in GitHub Desktop.
Save busypeoples/26595bb9713c1844fcb1 to your computer and use it in GitHub Desktop.
import React from 'react'
import { shallow, mount, render } from 'enzyme'
import Root, { SearchBar, ReleaseTable, Release } from '../src/Root'
const createShallowRelease = (outOfPrint = true) => {
let props = {release: { artist: 'foobar', title: 'bar', outOfPrint }};
return shallow(<Release {...props} />);
};
describe('<Release>', () => {
it('contains the class name release', () => {
let release = createShallowRelease();
expect(release.is('.release')).toBeTruthy();
});
it ('contains the class name outOfPrint if out of print', () => {
let release = createShallowRelease(true);
expect(release.is('.outOfPrint')).toBeTruthy();
});
it ('does not contain the class name outOfPrint if available', () => {
let release = createShallowRelease(false);
expect(release.is('.outOfPrint')).toBeFalsy();
});
it ('renders the artist name', () => {
let release = createShallowRelease();
expect(release.find('.artist').text()).toEqual('foobar');
});
it ('renders the release title', () => {
let release = createShallowRelease();
expect(release.find('.title').text()).toEqual('bar');
});
it ('renders the correct comment', () => {
let release = createShallowRelease(true);
expect(release.find('.comment').text()).toEqual('Out Of Print!');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment