Commit Graph

141 Commits

Author SHA1 Message Date
Ben Alpert bfcad9614a Warn when accessing .props, .setProps on DOM components 2015-06-08 10:36:20 -07:00
Paul O’Shannessy 2b195cb1ca Merge pull request #3941 from troutowicz/testing_type
Assert instance type using internal constructor
2015-06-04 13:31:23 -07:00
Ben Alpert 12ea09a03c Remove web worker test 2015-05-27 10:52:32 -07:00
Tim Routowicz f1e32a06e0 Assert instance type using internal constructor 2015-05-22 16:13:06 -04:00
Sławomir Laskowski 2c83627ca8 Add shallow context pass test 2015-05-21 00:08:31 +02:00
Ben Alpert 93a782b40b Use Babel to build React
Size comparison:

```
   raw     gz Compared to master @ 6ed98ec0c8
     =      = build/JSXTransformer.js
-15736  -3247 build/react-with-addons.js
  +287     +7 build/react-with-addons.min.js
-14412  -2887 build/react.js
  +274    +15 build/react.min.js
```

Differences mostly look to be various bits of whitespace that Babel ends up removing during its transforms (https://gist.github.com/spicyj/21ef31f4d95fb7a58daf). In minified files, mostly additions of `"use strict";`.
2015-05-04 14:14:09 -07:00
Scott Feeney df937af91c Shallow render components that define contextTypes
You now no longer have to pass an undocumented extra argument to the
shallow renderer for rendering components with contextTypes to work.

Fixes #3696
2015-04-21 16:17:06 -07:00
Ben Alpert d8117d0df6 Merge pull request #1366 from spicyj/enterleave-testutils
Make Simulate.mouseEnter/Leave use direct dispatch
2015-04-13 15:39:54 -07:00
Ben Alpert 9260b540ad Merge pull request #3467 from spicyj/valid-3
Validate node nesting, take 3
2015-03-24 13:30:16 -07:00
Ben Alpert f9abf493b4 Validate node nesting, take 3
Nicer version of #644 and #735. Fixes #101. Context is neat.
2015-03-20 16:10:02 -07:00
Ben Alpert e791fccf58 Use console.error to show stack trace in console
Better version of #3277.

Test Plan: jest, grunt test
2015-03-17 13:39:04 -07:00
Paul O’Shannessy 10112672b1 Merge pull request #3395 from Simek/reactComponentExpect-cleanup
toBeDOMComponentWithChildCount readability
2015-03-16 16:14:48 -07:00
Paul O’Shannessy 99cbaed836 Ensure FullPageComponents are treated as DOM components
We currently override a couple DOM components. We need to ensure everything we
override is still treated as a DOM component, even if it has a composite
component wrapper.
2015-03-16 15:18:39 -07:00
Ben Alpert 0a312bba89 Merge pull request #3414 from spicyj/gh-3407
Fix up Perf a bit better for 0.13
2015-03-16 14:04:28 -07:00
Ben Alpert 98671fda1a Fix up Perf a bit better for 0.13
_mountImageIntoNode moved into ReactMount and wasn't being counted where it was supposed to be. In addition, all DOM elements are now wrapped in a composite wrapper but for the perf tools we want to skip over those or else we'll double-count (at least with the current accounting -- and that's effectively what we did before so this brings us back up to parity).

Fixes #3407.

Test Plan:
Used the jsbin from #3407 and saw similar output from this branch and 0.12:

![image](https://cloud.githubusercontent.com/assets/6820/6649816/4d7202e0-c9b2-11e4-9364-e1b50c96b55b.png)
2015-03-13 18:51:53 -07:00
Ben Alpert 70985ba68d Squash getDOMNode warning from isDOMComponent
Fixes #3329.
2015-03-13 17:11:02 -07:00
Bartosz Kaszubowski 4b1d7bcec2 toBeDOMComponentWithChildCount readability 2015-03-13 00:15:32 +01:00
cpojer ae7da3aadd foo.getDOMNode => React.findDOMNode(foo) 2015-03-10 17:17:21 -07:00
Toru Kobayashi 29506cec54 Fix Perf displayName with ES6 classes 2015-03-10 09:45:40 +09:00
Christoph Pojer 8ce9e2b194 Update reactComponentExpect.js 2015-03-06 02:46:33 -08:00
Ben Alpert feae9ad0a8 Add regression test for scry order
Fixes #2978.
2015-02-26 15:54:50 -08:00
yungsters e9e33b984f Support unmounting in ReactShallowRenderer
Reviewers: @sebmarkbage, @zpao

Test Plan:

```
$ npm test ReactTestUtils
```
2015-02-18 17:45:42 -08:00
yungsters e952869ff8 Support rendering to null in ShallowComponentRenderer
Reviewers: @sema, @zpao

Test Plan:
```
$ npm jest
```
2015-02-18 11:31:02 -08:00
Ben Alpert 6b03975395 Make Simulate.mouseEnter/Leave use direct dispatch
Fixes #1297.

onMouseEnter and onMouseLeave shouldn't *actually* use direct dispatch, but doing so is more useful than doing nothing (and I don't think it precludes adding proper enter/leave dispatching later, either).

Test Plan:
grunt test
2015-02-16 16:12:19 -08:00
Henry Zhu cb49492f88 lint whitespace
- use spaces
- remove space before paren in function
-  remove space before colon in object
2015-02-14 11:12:18 -05:00
Henry Zhu e2a57920da lint whitespace , trailing comma 2015-02-13 23:13:47 -05:00
Rick Beerendonk 3e0750a4ad Update copyright headers for 2015 2015-01-31 20:18:25 +01:00
Sebastian Markbage 3bbf6ce1a5 Add Meta Matchers for Testing Tests
This adds a matcher called toEqualSpecsIn which executes two test suites,
without reporting the result. It then compares the specs and the number
of expects executed by each spec.

This will be used to ensure that tests written in other languages test the
same thing as the base line, ES6 classes.

Sets up CoffeeScript equivalence test.
2015-01-26 15:50:57 -08:00
Sebastian Markbage 766a79c695 Move component class instantiation into ReactCompositeComponent
We need to move instantiation into the mount phase for context purposes.

To do this I moved the shallow rendering stuff into ReactTestUtils and
reused more of the existing code for it by instantiating a noop child.

Everywhere we refer to the "type" we should pass it to ReactNativeComponent
to resolve any string value into the underlying composite.
2015-01-23 10:09:45 -08:00
Isaac Salier-Hellendag de54d84051 Repair ReactDefaultPerf
Update ReactDefaultPerf to properly record component names.
2015-01-21 10:52:43 -06:00
Paul O’Shannessy 967435b249 Revert "Merge pull request #2814 from jsfb/testutils-consolemock"
This reverts commit 9514861d93, reversing
changes made to cdec83732d.
2015-01-15 13:35:57 -08:00
Paul O’Shannessy df64a67b7f codemod "use strict" to 'use strict' for better linting 2015-01-13 15:26:32 -08:00
Jim bd4aff062d Added jasmine matcher that expects calls to console.warn. 2015-01-06 14:05:37 -08:00
Paul O’Shannessy 63d8e0c144 Fix lint 2014-12-14 15:22:24 -08:00
Paul O’Shannessy c9fb5b258e Add toBeTextComponentWithValue to reactComponentExpect
This was previously possible by looking at renderedChildren and props
but this feels better.
2014-12-14 14:12:29 -08:00
Jim 74f5b21758 Fixed ReactTestUtils scry for TextComponents. Fixes issue #2654. 2014-12-11 13:12:35 -08:00
Paul O’Shannessy 739baa9092 Fix new lint errors
We'll get to lint parity soon and then not need to do this.
2014-12-08 12:18:41 -08:00
Paul O’Shannessy c48b877253 Merge pull request #2596 from sebmarkbage/rce
reactComponentExpect expects itself
2014-11-26 11:10:00 -08:00
Paul O’Shannessy b7b74b7efe Fix lint warnings, style fixups
Followup work for recent PRs
2014-11-25 15:06:30 -08:00
Sebastian Markbage a530f1c379 reactComponentExpect expects itself
This was a bug when reactComponentExpectInternal was separated from
the normal reactComponentExpect flow.
2014-11-24 18:48:41 -08:00
yungsters fc7cf2ff63 Replace mountDepth with isTopLevel
Summary:
After #2570, `mountDepth` is only used to enforce that `setProps` and `replaceProps` is only invoked on the top-level component. This replaces `mountDepth` with a simpler `isTopLevel` boolean set by `ReactMount` which reduces the surface area of the internal API and removes the need to thread `mountDepth` throughout React core.

Reviewers: @sebmarkbage @zpao

Test Plan:
Ran unit tests successfully:

```
npm run jest
```
2014-11-19 13:13:08 -08:00
yungsters bda199de04 Preserve Implicit Method Names
Summary:
Changes the way we instrument methods for `ReactPerf` so that developer tools can assign implicit method names to measured functions.

Reviewers: @zpao @sebmarkbage
2014-11-18 12:48:58 -08:00
Jim 081feeb2dd Added warning if owner-based and parent-based contexts differ. 2014-11-17 17:02:20 -08:00
Sebastian Markbage 974a4c84ce Move mountComponentIntoNode and setProps out of ReactComponent
This is part of moving more logic out of the base classes.

setProps, replaceProps etc. are not accessible from anything other than
ReactClass so we can safely move it to ReactCompositeComponent.

mountComponentIntoNode is tightly coupled to ReactMount. It's part of the
outer abstraction, the mount point, not the individual component.
2014-11-17 12:54:21 -08:00
Scott Feeney bfadafe5d0 Shallow rendering support (#2393)
Now handles updating. Haven't looked at refs yet.
2014-11-17 10:47:18 -08:00
Sebastian Markbage dac59d1032 Drop the _owner and _lifeCycle field on internal instances
The _owner field is unnecessary since it's reachable from _currentElement.

The _lifeCycle field is unnecessary because an internal component should
not even need to exist at all if it's unmounted. It should be dereferenced
internally, and never exposed externally.

The only case where it's important is for batching updates where we
currently avoid calling performUpdateIfNecessary if it's mounted. However,
this function is already only executed "if necessary" so we just make sure
that it's not necessary after unmount by resetting all the pending fields.
2014-11-16 21:05:12 -08:00
Sebastian Markbage 9c3e2d833d Wrap every DOM node in a Composite Component
...unless they already have a wrapper. Also, add tagName to every wrapper.

This ensures that refs are consistent. They always look like composite
components. This effectively hides the internal implementation details of
real DOM components since you can no longer get a ref to one.

In the future we might want to drop this wrapper and have refs refer
directly to the DOM node.

I currently use a hacky way of auto-wrapping inside of ReactNativeComponent
so that any given string can be wrapped. Better suggestions are welcome.
2014-11-16 10:32:46 -08:00
Ben Alpert 795290d1b0 Fix problems with empty component ID registration
Fixes #2493, also closes #2353 as it incorporates a variant of that fix.

- Instead of having getEmptyComponent return `<noscript />` directly, wrap it in a class that we can easily identify later as being an empty component
- Cache the empty component element instead of recreating one each time
- Avoid touching the nullComponentIdsRegistry dictionary at all when not dealing with empty components
- Move empty-component tests to a separate file

Test Plan: jest
2014-11-15 12:35:11 -08:00
Ben Alpert 230115da92 Make ReactTextComponent properly injectable
ReactTextComponent's implementation is DOM-specific; instead of flattenChildren creating the ReactTextComponent instances, ReactNativeComponent now takes care of having ReactTextComponent injected and creating the component instance. I also renamed ReactTextComponent to ReactDOMTextComponent and moved it to browser/ui/ where it belongs. ReactDOMTextComponent no longer inherits directly from ReactComponent and instead implements construct and {mount,receive,unmount}Component directly.

This diff removes `ReactTestUtils.isTextComponent` which should have previously never returned true when using public APIs.

Test Plan: jest, use ballmer-peak example.
2014-11-15 12:30:42 -08:00
Sebastian Markbage 27c482a2b8 Separate React Composite and Class
ReactClass is now composed by ReactCompositeComponent rather than
inherit from it.

The state transition functions currently use ReactInstanceMap to map an
instance back to an internal representation.

I updated some tests to use public APIs. Other unit tests still reach into
internals but now we can find them using ReactInstanceMap.

I will do more cleanup in follow ups. The purpose of this diff is to
preserve semantics and most of the existing code.

This effectively enables support for ES6 classes. All you would need to
expose is ReactClassMixin.
2014-11-06 19:49:33 -08:00