File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import 'raf/polyfill';
2
2
import { configure } from 'enzyme' ;
3
3
import Adapter from 'enzyme-adapter-react-16' ;
4
4
import ReactDOM from 'react-dom' ;
5
+ import { clearInstances } from './src/HelmetData' ;
5
6
6
7
configure ( { adapter : new Adapter ( ) } ) ;
7
8
@@ -40,4 +41,5 @@ beforeEach(() => {
40
41
41
42
afterEach ( ( ) => {
42
43
ReactDOM . unmountComponentAtNode ( mount ) ;
44
+ clearInstances ( ) ;
43
45
} ) ;
Original file line number Diff line number Diff line change 1
1
import mapStateOnServer from './server' ;
2
2
3
- export default class HelmetData {
4
- instances = [ ] ;
3
+ const instances = [ ] ;
4
+
5
+ export function clearInstances ( ) {
6
+ instances . length = 0 ;
7
+ }
5
8
9
+ export default class HelmetData {
6
10
value = {
7
11
setHelmet : serverState => {
8
12
this . context . helmet = serverState ;
9
13
} ,
10
14
helmetInstances : {
11
- get : ( ) => this . instances ,
15
+ get : ( ) => instances ,
12
16
add : instance => {
13
- this . instances . push ( instance ) ;
17
+ instances . push ( instance ) ;
14
18
} ,
15
19
remove : instance => {
16
- const index = this . instances . indexOf ( instance ) ;
17
- this . instances . splice ( index , 1 ) ;
20
+ const index = instances . indexOf ( instance ) ;
21
+ instances . splice ( index , 1 ) ;
18
22
} ,
19
23
} ,
20
24
} ;
21
25
22
- constructor ( context , instances ) {
26
+ constructor ( context ) {
23
27
this . context = context ;
24
28
25
- if ( instances ) {
26
- this . instances = instances ;
27
- }
28
-
29
29
if ( ! HelmetData . canUseDOM ) {
30
30
context . helmet = mapStateOnServer ( {
31
31
baseTag : [ ] ,
You can’t perform that action at this time.
0 commit comments