File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,51 @@ describe('Container', () => {
57
57
} ) ;
58
58
} ) ;
59
59
60
+ describe ( 'when there is an error in the component' , ( ) => {
61
+ let expectedError ;
62
+
63
+ beforeEach ( ( ) => expectedError = new Error ( ) ) ;
64
+
65
+ it . only ( 'should be thrown rather than seeing react error' , ( ) => {
66
+ expect ( createComponentThatThrowsError ) . to . throw ( expectedError ) ;
67
+
68
+ function createComponentThatThrowsError ( ) {
69
+ app . register ( 'fooStore' , Marty . createStore ( {
70
+ setFoo ( ) {
71
+ this . state . foo = { id : 1 } ;
72
+ this . hasChanged ( ) ;
73
+ } ,
74
+ getFoo ( ) {
75
+ if ( this . state . foo ) {
76
+ return fetch . done ( this . state . foo ) ;
77
+ }
78
+
79
+ throw expectedError ;
80
+ }
81
+ } ) ) ;
82
+
83
+ let Foo = Marty . createContainer ( React . createClass ( {
84
+ render ( ) {
85
+ throw expectedError ;
86
+ }
87
+ } ) , {
88
+ listenTo : 'fooStore' ,
89
+ fetch : {
90
+ foo ( ) {
91
+ return this . app . fooStore . getFoo ( ) ;
92
+ }
93
+ } ,
94
+ pending ( ) {
95
+ return < div > Foo</ div > ;
96
+ }
97
+ } ) ;
98
+
99
+ renderIntoDocument ( < Foo app = { app } /> ) ;
100
+ app . fooStore . setFoo ( ) ;
101
+ }
102
+ } ) ;
103
+ } ) ;
104
+
60
105
describe ( 'when I dont pass in an inner component' , ( ) => {
61
106
it ( 'should throw an error' , ( ) => {
62
107
expect ( createContainerWithNoInnerComponent ) . to . throw ( Error ) ;
You can’t perform that action at this time.
0 commit comments