@@ -6,24 +6,26 @@ import React from 'react';
66import sinon from 'sinon' ;
77import { expect } from 'chai' ;
88import { mount } from 'enzyme' ;
9+ import * as SizeMe from 'react-sizeme' ;
910import { describeWithDOM } from './jsdom' ;
1011
1112describeWithDOM ( 'Given the ComponentQueries library' , ( ) => {
1213 let componentQueries ;
1314 let sizeMeConfig ;
15+ let sinonSandbox ;
1416
1517 beforeEach ( ( ) => {
16- componentQueries = require ( '../src/componentQueries' ) . default ;
17-
18- // Set up our mocks.
19- const componentQueriesRewireAPI = componentQueries . __RewireAPI__ ;
18+ sinonSandbox = sinon . sandbox . create ( ) ;
2019
21- // Mock the SizeMe HOC to just return our ComponentQueries instance.
22- componentQueriesRewireAPI . __Rewire__ ( 'sizeMe' , config => {
20+ sinonSandbox . stub ( SizeMe , 'default' , config => {
2321 sizeMeConfig = config ; return x => x ;
2422 } ) ;
23+
24+ componentQueries = require ( '../src/componentQueries' ) . default ;
2525 } ) ;
2626
27+ afterEach ( ( ) => sinonSandbox . restore ( ) ) ;
28+
2729 describe ( 'When setting up the ComponentQueries HOC' , ( ) => {
2830 describe ( 'And no queries are provided' , ( ) => {
2931 it ( 'Then an error should be thrown' , ( ) => {
@@ -121,11 +123,6 @@ describeWithDOM('Given the ComponentQueries library', () => {
121123 } ) ;
122124
123125 describe ( 'When rendering a component queries component' , ( ) => {
124- let sinonSandbox ;
125-
126- beforeEach ( ( ) => { sinonSandbox = sinon . sandbox . create ( ) ; } ) ;
127- afterEach ( ( ) => sinonSandbox . restore ( ) ) ;
128-
129126 it ( 'Then it should receive the appropriate props based on it\'s queries' , ( ) => {
130127 let receivedProps ;
131128
0 commit comments