Sha256: 7f03482d579c40d3d189dfc0e072ce044fa8ea4d8d78f94afdbed12b34c142e9

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

import BackgroundImage from 'components/background_image.jsx';

import renderComponent from '../support/render_component';

describe('BackgroundImage', () => {
  it('has image file css class', () => {
    var backgroundImage = renderComponent(BackgroundImage, {imageFileId: 5});

    expect(backgroundImage.props.className.split(' ')).to.contain('image_5');
  });

  it('has image_none css class if not imageFileId is given', () => {
    var backgroundImage = renderComponent(BackgroundImage);

    expect(backgroundImage.props.className.split(' ')).to.contain('image_none');
  });

  it('has load_image css class if loaded prop is present', () => {
    var backgroundImage = renderComponent(BackgroundImage, {imageFileId: 5, loaded: true});

    expect(backgroundImage.props.className.split(' ')).to.contain('load_image');
  });

  it('has image file css class', () => {
    var backgroundImage = renderComponent(BackgroundImage, {imageFileId: 5});

    expect(backgroundImage.props.className.split(' ')).to.contain('image_5');
  });

  it('defaults background position to center', () => {
    var backgroundImage = renderComponent(BackgroundImage, {imageFileId: 5});

    expect(backgroundImage.props.style.backgroundPosition).to.eq('50% 50%');
  });

  it('defaults background position to center', () => {
    var backgroundImage = renderComponent(BackgroundImage, {imageFileId: 5, position: [undefined, undefined]});

    expect(backgroundImage.props.style.backgroundPosition).to.eq('50% 50%');
  });

  it('sets background position inline styles', () => {
    var backgroundImage = renderComponent(BackgroundImage, {imageFileId: 5, position: [10, 20]});

    expect(backgroundImage.props.style.backgroundPosition).to.eq('10% 20%');
  });
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pageflow-react-0.1.1 js/spec/components/background_image_spec.js
pageflow-react-0.1.0 js/spec/components/background_image_spec.js