@@ -99,6 +99,7 @@ describe('<GojsDiagram />', () => {
9999 } ;
100100
101101 const myDiagramId = 'myDiagramId' ;
102+ const modelData = { test : 'modeldatata' } ;
102103
103104 const defaultSelectedNodeKey = 'Beta' ;
104105
@@ -107,6 +108,10 @@ describe('<GojsDiagram />', () => {
107108 let modelChangeCallback ;
108109 let keyIndex = 0 ;
109110
111+ const dom = document . body ;
112+ const rootDiv = document . createElement ( 'div' ) ;
113+ dom . appendChild ( rootDiv ) ;
114+
110115 beforeEach ( ( ) => {
111116 Element . prototype . getBoundingClientRect = function ( ) {
112117 return {
@@ -116,20 +121,18 @@ describe('<GojsDiagram />', () => {
116121 left : 0 ,
117122 x : 0 ,
118123 y : 0 ,
119- toJSON : ( ) => {
120- console . log ( 'test' ) ;
121- } ,
124+ toJSON : ( ) => '' ,
122125 bottom : 0 ,
123126 right : 0
124127 } ;
125128 } ;
126129 keyIndex = 0 ;
127- const dom = document . body ;
128130 modelChangeCallback = jest . fn ( ) ;
129131 wrapper = mount (
130132 < GojsDiagram
131133 diagramId = { myDiagramId }
132134 model = { model }
135+ initialModelData = { modelData }
133136 createDiagram = { id => {
134137 diagram = createDiagram ( myDiagramId ) ;
135138 return diagram ;
@@ -158,7 +161,7 @@ describe('<GojsDiagram />', () => {
158161 } }
159162 defaultSelectedNode = { defaultSelectedNodeKey }
160163 /> ,
161- { attachTo : dom }
164+ { attachTo : rootDiv }
162165 ) ;
163166 jest . runAllTimers ( ) ;
164167 } ) ;
@@ -167,6 +170,10 @@ describe('<GojsDiagram />', () => {
167170 expect ( diagram . model . nodeCategoryProperty === 'category' ) . toBeTruthy ( ) ;
168171 } ) ;
169172
173+ it ( 'should initialize the modelData' , ( ) => {
174+ expect ( diagram . model . modelData ) . toBe ( modelData ) ;
175+ } ) ;
176+
170177 it ( 'should render links and nodes in the diagram based on the model provided as prop' , ( ) => {
171178 checkIfDiagramRendersModel ( model , diagram ) ;
172179 } ) ;
0 commit comments