summaryrefslogtreecommitdiffstats
path: root/lib/__tests__/Rating-test.js
blob: 75734cc5a2729870e0553425ce30c4b95f55c300 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var React = require('react/addons');
var TestUtils = React.addons.TestUtils;
var expect = require('expect');
var {Rating, RatingIcon} = require('../');

describe('Rating', function() {

  it('should render 5 RatingIcons as default', function() {
    var ratingWrapper = TestUtils.renderIntoDocument(
      <div>
        <Rating onRate={() => {}} />
      </div>
    );

    var ratingIcons = TestUtils.scryRenderedComponentsWithType(ratingWrapper, RatingIcon);
    expect(ratingIcons.length).toBe(5, 'Rating is not rendering 5 icons as default');
  });

  it('should render 3 RatingIcons', function() {
    var ratingWrapper = TestUtils.renderIntoDocument(
      <div>
        <Rating onRate={() => {}} maxRating={3} />
      </div>
    );

    var ratingIcons = TestUtils.scryRenderedComponentsWithType(ratingWrapper, RatingIcon);
    expect(ratingIcons.length).toBe(3, 'Rating is not renderin 3 icons');
  });

});