@@ -23,13 +23,15 @@ describe('hitsPerPageSelector()', () => {
2323 let helper ;
2424 let results ;
2525 let autoHideContainer ;
26+ let consoleLog ;
2627
2728 beforeEach ( ( ) => {
2829 autoHideContainer = sinon . stub ( ) . returns ( Selector ) ;
2930 ReactDOM = { render : sinon . spy ( ) } ;
3031
3132 hitsPerPageSelector . __Rewire__ ( 'ReactDOM' , ReactDOM ) ;
3233 hitsPerPageSelector . __Rewire__ ( 'autoHideContainer' , autoHideContainer ) ;
34+ consoleLog = sinon . spy ( window . console , 'log' ) ;
3335
3436 container = document . createElement ( 'div' ) ;
3537 options = [
@@ -90,16 +92,16 @@ describe('hitsPerPageSelector()', () => {
9092 it ( 'should throw if there is no name attribute in a passed object' , ( ) => {
9193 options . length = 0 ;
9294 options . push ( { label : 'Label without a value' } ) ;
93- expect ( ( ) => {
94- widget . init ( helper . state , helper ) ;
95- } ) . toThrow ( / N o o p t i o n i n ` o p t i o n s ` w i t h ` v a l u e : 2 0 ` / ) ;
95+ widget . init ( helper . state , helper ) ;
96+ expect ( consoleLog . calledOnce ) . toBe ( true , 'console.log called once' ) ;
97+ expect ( consoleLog . firstCall . args [ 0 ] ) . toMatch ( / N o o p t i o n i n ` o p t i o n s ` w i t h ` v a l u e : h i t s P e r P a g e ` \( h i t s P e r P a g e : 2 0 \) / ) ;
9698 } ) ;
9799
98100 it ( 'must include the current hitsPerPage at initialization time' , ( ) => {
99101 helper . state . hitsPerPage = - 1 ;
100- expect ( ( ) => {
101- widget . init ( helper . state , helper ) ;
102- } ) . toThrow ( / N o o p t i o n i n ` o p t i o n s ` w i t h ` v a l u e : - 1 ` / ) ;
102+ widget . init ( helper . state , helper ) ;
103+ expect ( consoleLog . calledOnce ) . toBe ( true , 'console.log called once' ) ;
104+ expect ( consoleLog . firstCall . args [ 0 ] ) . toMatch ( / N o o p t i o n i n ` o p t i o n s ` w i t h ` v a l u e : h i t s P e r P a g e ` \( h i t s P e r P a g e : - 1 \) / ) ;
103105 } ) ;
104106
105107 it ( 'should not throw an error if state does not have a `hitsPerPage`' , ( ) => {
@@ -112,5 +114,6 @@ describe('hitsPerPageSelector()', () => {
112114 afterEach ( ( ) => {
113115 hitsPerPageSelector . __ResetDependency__ ( 'ReactDOM' ) ;
114116 hitsPerPageSelector . __ResetDependency__ ( 'autoHideContainer' ) ;
117+ consoleLog . restore ( ) ;
115118 } ) ;
116119} ) ;
0 commit comments