Skip to content

Commit c180e22

Browse files
committed
Trying to replicate martyjs/marty#319
1 parent 1de2caa commit c180e22

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/container/__tests__/containerSpec.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,51 @@ describe('Container', () => {
5757
});
5858
});
5959

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+
60105
describe('when I dont pass in an inner component', () => {
61106
it('should throw an error', () => {
62107
expect(createContainerWithNoInnerComponent).to.throw(Error);

0 commit comments

Comments
 (0)