Remove unused createHierarchyRenderer (#7454)
Paul O’Shannessy committed
Aug 9, 2016 at 16:03 UTC
c848b65378ac15b5b98a1e486f76945e9a6426c1
1 file changed
-82
src/test/createHierarchyRenderer.js
deleted
-82
@@ -1,82 +0,0 @@
1
-/**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule createHierarchyRenderer
10
- */
11
-
12
-'use strict';
13
-
14
-var React = require('React');
15
-
16
-/**
17
- * Creates a render method that makes it easier to create, render, and inspect a
18
- * hierarchy of mock React component classes.
19
- *
20
- * A component class is created for each of the supplied render methods. Each
21
- * render method is invoked with the classes created using the render methods
22
- * that come after it in the supplied list of render methods.
23
- *
24
- * var renderHierarchy = createHierarchyRenderer(
25
- * function ComponentA(ComponentB, ComponentC) {...},
26
- * function ComponentB(ComponentC) {...},
27
- * function ComponentC() {...}
28
- * );
29
- *
30
- * When the hierarchy is invoked, a two-dimensional array is returned. Each
31
- * array corresponds to a supplied render method and contains the instances
32
- * returned by that render method in the order it was invoked.
33
- *
34
- * var instances = renderHierarchy(
35
- * function(ComponentA[, ComponentB, ComponentC]) {
36
- * ReactDOM.render(<ComponentA />, ...);
37
- * })
38
- * );
39
- * instances[0][0]; // First return value of first render method.
40
- * instances[1][0]; // First return value of second render method.
41
- * instances[1][1]; // Second return value of second render method.
42
- *
43
- * Refs should be used to reference components that are not the return value of
44
- * render methods.
45
- *
46
- * expect(instances[0][0].refs.X).toBe(...);
47
- *
48
- * NOTE: The component classes created for each render method are re-used for
49
- * each invocation of the hierarchy renderer. If new classes are needed, you
50
- * should re-execute `createHierarchyRenderer` with the same arguments.
51
- *
52
- * @param {array<function>} ...renderMethods
53
- * @return {function}
54
- */
55
-function createHierarchyRenderer(...renderMethods) {
56
- var instances;
57
- var Components = renderMethods.reduceRight(
58
- function(ComponentsAccumulator, renderMethod, depth) {
59
- var Component = React.createClass({
60
- displayName: renderMethod.name,
61
- render: function() {
62
- instances[depth].push(this);
63
- return renderMethod.apply(this, ComponentsAccumulator);
64
- },
65
- });
66
- return [Component].concat(ComponentsAccumulator);
67
- },
68
- []
69
- );
70
- /**
71
- * @param {function} renderComponent
72
- * @return {array<array<*>>}
73
- */
74
- function renderHierarchy(renderComponent) {
75
- instances = renderMethods.map(() => []);
76
- renderComponent.apply(null, Components);
77
- return instances;
78
- }
79
- return renderHierarchy;
80
-}
81
-
82
-module.exports = createHierarchyRenderer;