Skip to content

Commit

Permalink
fix(react-media): Allow Media to take a className.
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Meskers <pmeskers@pivotal.io>
  • Loading branch information
mdelillo authored and Paul Meskers committed Feb 2, 2015
1 parent 02bb247 commit d4c10b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/pivotal-ui/javascripts/media.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ var Media = React.createClass({
'media-stackable-lg': stackSize === 'large'
});

if (this.props.className) {
classes += ' ' + this.props.className;
}

var bodyClasses = setClass({
'media-body': true,
'media-middle': vAlign === 'middle',
Expand Down
9 changes: 6 additions & 3 deletions test/javascripts/media_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('Media', function() {
React.render(
Media({
children: "fop",
className: "media-class",
leftImage: image
}),
this.node
Expand All @@ -34,9 +35,11 @@ describe('Media', function() {
it("creates a Media component", function() {
expect($('#container .media .media-body')).toContainText('fop');
});
});


it("passes the provided className onto the .media element", function() {
expect($('#container .media')).toHaveClass('media-class');
});
});

describe("when left image src is set", function() {
describe("when left image src is set", function() {
Expand All @@ -54,7 +57,7 @@ describe('Media', function() {
it("displays the media-left link with an image inside", function() {
expect($('#container .media .media-left img').attr('src')).toEqual('http://placehold.it/20x20');
});

it("sets an alt on the left image when the leftAlt property is set", function() {
expect($('#container .media .media-left img').attr('alt')).toEqual('my fancy image description');
});
Expand Down

0 comments on commit d4c10b2

Please sign in to comment.