@@ -6,24 +6,26 @@ import React from 'react';
6
6
import sinon from 'sinon' ;
7
7
import { expect } from 'chai' ;
8
8
import { mount } from 'enzyme' ;
9
+ import * as SizeMe from 'react-sizeme' ;
9
10
import { describeWithDOM } from './jsdom' ;
10
11
11
12
describeWithDOM ( 'Given the ComponentQueries library' , ( ) => {
12
13
let componentQueries ;
13
14
let sizeMeConfig ;
15
+ let sinonSandbox ;
14
16
15
17
beforeEach ( ( ) => {
16
- componentQueries = require ( '../src/componentQueries' ) . default ;
17
-
18
- // Set up our mocks.
19
- const componentQueriesRewireAPI = componentQueries . __RewireAPI__ ;
18
+ sinonSandbox = sinon . sandbox . create ( ) ;
20
19
21
- // Mock the SizeMe HOC to just return our ComponentQueries instance.
22
- componentQueriesRewireAPI . __Rewire__ ( 'sizeMe' , config => {
20
+ sinonSandbox . stub ( SizeMe , 'default' , config => {
23
21
sizeMeConfig = config ; return x => x ;
24
22
} ) ;
23
+
24
+ componentQueries = require ( '../src/componentQueries' ) . default ;
25
25
} ) ;
26
26
27
+ afterEach ( ( ) => sinonSandbox . restore ( ) ) ;
28
+
27
29
describe ( 'When setting up the ComponentQueries HOC' , ( ) => {
28
30
describe ( 'And no queries are provided' , ( ) => {
29
31
it ( 'Then an error should be thrown' , ( ) => {
@@ -121,11 +123,6 @@ describeWithDOM('Given the ComponentQueries library', () => {
121
123
} ) ;
122
124
123
125
describe ( 'When rendering a component queries component' , ( ) => {
124
- let sinonSandbox ;
125
-
126
- beforeEach ( ( ) => { sinonSandbox = sinon . sandbox . create ( ) ; } ) ;
127
- afterEach ( ( ) => sinonSandbox . restore ( ) ) ;
128
-
129
126
it ( 'Then it should receive the appropriate props based on it\'s queries' , ( ) => {
130
127
let receivedProps ;
131
128
0 commit comments