@samitouri / QOS-React-2 / commits / d5989a0de4

tests for displaying `defaultValue` of 0

Cheng Lou committed Aug 12, 2013 at 16:08 UTC d5989a0de470384d33650e99190f53bb51b6d2af
1 file changed +47
src/dom/components/__tests__/ReactDOMTextarea-test.js
+47
@@ -51,6 +51,13 @@ describe('ReactDOMTextarea', function() {
51 expect(node.value).toEqual('giraffe');
52 });
53
54 + it('should display `defaultValue` of number 0', function() {
55 + var stub = <textarea defaultValue={0} />;
56 + var node = renderTextarea(stub);
57 +
58 + expect(node.value).toBe('0');
59 + });
60 +
61 it('should allow setting `value`', function() {
62 var stub = <textarea value="giraffe" />;
63 var node = renderTextarea(stub);
@@ -61,6 +68,13 @@ describe('ReactDOMTextarea', function() {
68 expect(node.value).toEqual('gorilla');
69 });
70
71 + it('should display `value` of number 0', function() {
72 + var stub = <textarea value={0} />;
73 + var node = renderTextarea(stub);
74 +
75 + expect(node.value).toBe('0');
76 + });
77 +
78 it('should treat children like `defaultValue`', function() {
79 spyOn(console, 'warn');
80
@@ -102,3 +116,36 @@ describe('ReactDOMTextarea', function() {
116 expect(console.warn.argsForCall.length).toBe(2);
117 });
118 });
119 +
120 +describe('ReactDOMInput', function() {
121 + var React;
122 + var ReactTestUtils;
123 +
124 + var renderTextarea;
125 +
126 + beforeEach(function() {
127 + React = require('React');
128 + ReactTestUtils = require('ReactTestUtils');
129 +
130 + renderTextarea = function(component) {
131 + var stub = ReactTestUtils.renderIntoDocument(component);
132 + var node = stub.getDOMNode();
133 + return node;
134 + };
135 + });
136 +
137 + it('should display `defaultValue` of number 0', function() {
138 + var stub = <input type="text" defaultValue={0} />;
139 + var node = renderTextarea(stub);
140 +
141 + expect(node.value).toBe('0');
142 + });
143 +
144 + it('should display `value` of number 0', function() {
145 + var stub = <input type="text" value={0} />;
146 + var node = renderTextarea(stub);
147 +
148 + expect(node.value).toBe('0');
149 + });
150 +
151 +});