aboutsummaryrefslogtreecommitdiff
path: root/thirdparty/preact/test/browser/context.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-11-08 15:07:07 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-11-08 15:19:39 +0100
commitafb9fba64be1f15a3ce3ed31214a704e73e5e8bb (patch)
tree6f69712a8c976178c05144483ff0c8e9b09445c8 /thirdparty/preact/test/browser/context.js
parentb37e7762bb5492cbd6788863232e7d2634ab5e5c (diff)
parent6e5fb04d3f3f9a6cd43ac20896d73321dd079f96 (diff)
Update preact version
Diffstat (limited to 'thirdparty/preact/test/browser/context.js')
-rw-r--r--thirdparty/preact/test/browser/context.js32
1 files changed, 18 insertions, 14 deletions
diff --git a/thirdparty/preact/test/browser/context.js b/thirdparty/preact/test/browser/context.js
index e62a948a4..ed5f81471 100644
--- a/thirdparty/preact/test/browser/context.js
+++ b/thirdparty/preact/test/browser/context.js
@@ -1,6 +1,8 @@
import { h, render, Component } from '../../src/preact';
/** @jsx h */
+const CHILDREN_MATCHER = sinon.match( v => v==null || Array.isArray(v) && !v.length , '[empty children]');
+
describe('context', () => {
let scratch;
@@ -57,18 +59,19 @@ describe('context', () => {
expect(Outer.prototype.getChildContext).to.have.been.calledOnce;
// initial render does not invoke anything but render():
- expect(Inner.prototype.render).to.have.been.calledWith({}, {}, CONTEXT);
+ expect(Inner.prototype.render).to.have.been.calledWith({ children:CHILDREN_MATCHER }, {}, CONTEXT);
CONTEXT.foo = 'bar';
render(<Outer {...PROPS} />, scratch, scratch.lastChild);
expect(Outer.prototype.getChildContext).to.have.been.calledTwice;
- expect(Inner.prototype.shouldComponentUpdate).to.have.been.calledOnce.and.calledWith(PROPS, {}, CONTEXT);
- expect(Inner.prototype.componentWillReceiveProps).to.have.been.calledWith(PROPS, CONTEXT);
- expect(Inner.prototype.componentWillUpdate).to.have.been.calledWith(PROPS, {});
- expect(Inner.prototype.componentDidUpdate).to.have.been.calledWith({}, {});
- expect(Inner.prototype.render).to.have.been.calledWith(PROPS, {}, CONTEXT);
+ let props = { children: CHILDREN_MATCHER, ...PROPS };
+ expect(Inner.prototype.shouldComponentUpdate).to.have.been.calledOnce.and.calledWith(props, {}, CONTEXT);
+ expect(Inner.prototype.componentWillReceiveProps).to.have.been.calledWith(props, CONTEXT);
+ expect(Inner.prototype.componentWillUpdate).to.have.been.calledWith(props, {});
+ expect(Inner.prototype.componentDidUpdate).to.have.been.calledWith({ children:CHILDREN_MATCHER }, {});
+ expect(Inner.prototype.render).to.have.been.calledWith(props, {}, CONTEXT);
/* Future:
@@ -115,18 +118,19 @@ describe('context', () => {
expect(Outer.prototype.getChildContext).to.have.been.calledOnce;
// initial render does not invoke anything but render():
- expect(Inner.prototype.render).to.have.been.calledWith({}, {}, CONTEXT);
+ expect(Inner.prototype.render).to.have.been.calledWith({ children: CHILDREN_MATCHER }, {}, CONTEXT);
CONTEXT.foo = 'bar';
render(<Outer {...PROPS} />, scratch, scratch.lastChild);
expect(Outer.prototype.getChildContext).to.have.been.calledTwice;
- expect(Inner.prototype.shouldComponentUpdate).to.have.been.calledOnce.and.calledWith(PROPS, {}, CONTEXT);
- expect(Inner.prototype.componentWillReceiveProps).to.have.been.calledWith(PROPS, CONTEXT);
- expect(Inner.prototype.componentWillUpdate).to.have.been.calledWith(PROPS, {});
- expect(Inner.prototype.componentDidUpdate).to.have.been.calledWith({}, {});
- expect(Inner.prototype.render).to.have.been.calledWith(PROPS, {}, CONTEXT);
+ let props = { children: CHILDREN_MATCHER, ...PROPS };
+ expect(Inner.prototype.shouldComponentUpdate).to.have.been.calledOnce.and.calledWith(props, {}, CONTEXT);
+ expect(Inner.prototype.componentWillReceiveProps).to.have.been.calledWith(props, CONTEXT);
+ expect(Inner.prototype.componentWillUpdate).to.have.been.calledWith(props, {});
+ expect(Inner.prototype.componentDidUpdate).to.have.been.calledWith({ children: CHILDREN_MATCHER }, {});
+ expect(Inner.prototype.render).to.have.been.calledWith(props, {}, CONTEXT);
// make sure render() could make use of context.a
expect(Inner.prototype.render).to.have.returned(sinon.match({ children:['a'] }));
@@ -164,7 +168,7 @@ describe('context', () => {
render(<Outer />, scratch);
- expect(Inner.prototype.render).to.have.been.calledWith({}, {}, { outerContext });
- expect(InnerMost.prototype.render).to.have.been.calledWith({}, {}, { outerContext, innerContext });
+ expect(Inner.prototype.render).to.have.been.calledWith({ children: CHILDREN_MATCHER }, {}, { outerContext });
+ expect(InnerMost.prototype.render).to.have.been.calledWith({ children: CHILDREN_MATCHER }, {}, { outerContext, innerContext });
});
});