1+ import React from 'react' ;
12import expect from 'expect' ;
2- import style from '../../progress_bar/style' ;
3+ import TestUtils from 'react-addons-test-utils' ;
4+ import ProgressBar , { ProgressBar as RawProgressBar } from '../ProgressBar' ;
5+ import theme from '../theme.scss' ;
36import utils from '../../utils/testing' ;
4- import ProgressBar from '../index' ;
57
68describe ( 'ProgressBar' , function ( ) {
79 let progressBar ;
810
911 describe ( '#calculateRatio' , function ( ) {
1012 before ( function ( ) {
11- progressBar = utils . renderComponent ( ProgressBar , { min : 100 , max : 300 } ) ;
13+ const tree = TestUtils . renderIntoDocument ( < ProgressBar min = { 100 } max = { 300 } theme = { theme } /> ) ;
14+ progressBar = TestUtils . findRenderedComponentWithType ( tree , RawProgressBar ) ;
1215 } ) ;
1316
1417 it ( 'calculates the right ratio' , function ( ) {
@@ -28,37 +31,37 @@ describe('ProgressBar', function () {
2831 let buffer , value , wrapper , circle , strokeLength ;
2932
3033 it ( 'renders the value and buffer bars when it is linear' , function ( ) {
31- wrapper = utils . shallowRenderComponent ( ProgressBar ) . props . children ;
34+ wrapper = utils . shallowRenderComponent ( RawProgressBar , { theme } ) . props . children ;
3235 expect ( wrapper . props . children . length ) . toEqual ( 2 ) ;
3336 expect ( wrapper . props . children [ 0 ] . ref ) . toEqual ( 'buffer' ) ;
3437 expect ( wrapper . props . children [ 1 ] . ref ) . toEqual ( 'value' ) ;
3538 } ) ;
3639
3740 it ( 'renders the value and buffer bars when it is linear' , function ( ) {
38- progressBar = utils . shallowRenderComponent ( ProgressBar , { mode : 'determinate' , value : 30 , buffer : 60 } ) ;
41+ progressBar = utils . shallowRenderComponent ( RawProgressBar , { mode : 'determinate' , value : 30 , buffer : 60 , theme } ) ;
3942 buffer = ( progressBar . props . children . props . children [ 0 ] ) ;
4043 value = ( progressBar . props . children . props . children [ 1 ] ) ;
4144 expect ( buffer . props . style . transform ) . toEqual ( `scaleX(${ 0.6 } )` ) ;
4245 expect ( value . props . style . transform ) . toEqual ( `scaleX(${ 0.3 } )` ) ;
4346 } ) ;
4447
4548 it ( 'renders the svg circle when it is circular' , function ( ) {
46- progressBar = utils . shallowRenderComponent ( ProgressBar , { type : 'circular' } ) ;
49+ progressBar = utils . shallowRenderComponent ( RawProgressBar , { type : 'circular' , theme } ) ;
4750 expect ( progressBar . props . children . type ) . toEqual ( 'svg' ) ;
4851 expect ( progressBar . props . children . props . children . type ) . toEqual ( 'circle' ) ;
4952 } ) ;
5053
5154 it ( 'renders the proper circle length style when it is circular and determinate' , function ( ) {
52- progressBar = utils . shallowRenderComponent ( ProgressBar , { type : 'circular' , mode : 'determinate' , value : 30 } ) ;
55+ progressBar = utils . shallowRenderComponent ( RawProgressBar , { type : 'circular' , mode : 'determinate' , value : 30 , theme } ) ;
5356 circle = progressBar . props . children . props . children ;
5457 strokeLength = 2 * Math . PI * circle . props . r * 0.3 ;
5558 expect ( circle . props . style . strokeDasharray ) . toEqual ( `${ strokeLength } , 400` ) ;
5659 } ) ;
5760
5861 it ( 'contains mode and className in its className' , function ( ) {
59- progressBar = utils . shallowRenderComponent ( ProgressBar , { mode : 'determinate' , className : 'tight' } ) ;
60- expect ( progressBar . props . className ) . toContain ( style . determinate ) ;
61- expect ( progressBar . props . className ) . toContain ( style . tight ) ;
62+ progressBar = utils . shallowRenderComponent ( RawProgressBar , { mode : 'determinate' , className : 'tight' , theme } ) ;
63+ expect ( progressBar . props . className ) . toContain ( theme . determinate ) ;
64+ expect ( progressBar . props . className ) . toContain ( theme . tight ) ;
6265 } ) ;
6366 } ) ;
6467} ) ;
0 commit comments