@samitouri / QOS-React-2 / commits / 697bf73c5f

Add test for isValidDescriptor

Fixes #1164. Test Plan: grunt test

Ben Alpert committed Apr 9, 2014 at 22:53 UTC 697bf73c5f37049b1e9b048aa23007ca50f4b26d
1 file changed +48
src/core/__tests__/ReactDescriptor-test.js new
+48
@@ -0,0 +1,48 @@
1 +/**
2 + * Copyright 2013-2014 Facebook, Inc.
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + *
16 + * @jsx React.DOM
17 + * @emails react-core
18 + */
19 +
20 +"use strict";
21 +
22 +var React;
23 +var ReactDescriptor;
24 +
25 +describe('ReactDescriptor', function() {
26 + beforeEach(function() {
27 + React = require('React');
28 + ReactDescriptor = require('ReactDescriptor');
29 + });
30 +
31 + it('should identify valid descriptors correctly', function() {
32 + var Component = React.createClass({
33 + render: function() {
34 + return <div />;
35 + }
36 + });
37 +
38 + expect(ReactDescriptor.isValidDescriptor(<div />)).toEqual(true);
39 + expect(ReactDescriptor.isValidDescriptor(<Component />)).toEqual(true);
40 +
41 + expect(ReactDescriptor.isValidDescriptor(null)).toEqual(false);
42 + expect(ReactDescriptor.isValidDescriptor(true)).toEqual(false);
43 + expect(ReactDescriptor.isValidDescriptor({})).toEqual(false);
44 + expect(ReactDescriptor.isValidDescriptor("string")).toEqual(false);
45 + expect(ReactDescriptor.isValidDescriptor(React.DOM.div)).toEqual(false);
46 + expect(ReactDescriptor.isValidDescriptor(Component)).toEqual(false);
47 + });
48 +});