File tree Expand file tree Collapse file tree 2 files changed +3
-12
lines changed Expand file tree Collapse file tree 2 files changed +3
-12
lines changed Original file line number Diff line number Diff line change @@ -154,10 +154,7 @@ class ReactWrapper {
154154 * @return {ReactElement }
155155 */
156156 getElement ( ) {
157- if ( this . length !== 1 ) {
158- throw new Error ( 'ReactWrapper::getElement() can only be called when wrapping one node' ) ;
159- }
160- return getAdapter ( this [ OPTIONS ] ) . nodeToElement ( this [ NODE ] ) ;
157+ return this . single ( 'getElement' , ( ) => getAdapter ( this [ OPTIONS ] ) . nodeToElement ( this [ NODE ] ) ) ;
161158 }
162159
163160 /**
@@ -219,10 +216,7 @@ class ReactWrapper {
219216 * @returns {ReactComponent|DOMComponent }
220217 */
221218 instance ( ) {
222- if ( this . length !== 1 ) {
223- throw new Error ( 'ReactWrapper::instance() can only be called on single nodes' ) ;
224- }
225- return this [ NODE ] . instance ;
219+ return this . single ( 'instance' , ( ) => this [ NODE ] . instance ) ;
226220 }
227221
228222 /**
Original file line number Diff line number Diff line change @@ -273,10 +273,7 @@ class ShallowWrapper {
273273 * @return {ReactElement }
274274 */
275275 getElement ( ) {
276- if ( this . length !== 1 ) {
277- throw new Error ( 'ShallowWrapper::getElement() can only be called when wrapping one node' ) ;
278- }
279- return getAdapter ( this [ OPTIONS ] ) . nodeToElement ( this . getNodeInternal ( ) ) ;
276+ return this . single ( 'getElement' , n => getAdapter ( this [ OPTIONS ] ) . nodeToElement ( n ) ) ;
280277 }
281278
282279 /**
You can’t perform that action at this time.
0 commit comments