332
});
333
334
describe('basic rendering', function() {
335
+ beforeEach(() => {
336
+ onAfterResetModules = () => {
337
+ const ReactFeatureFlags = require('ReactFeatureFlags');
338
+ ReactFeatureFlags.disableNewFiberFeatures = false;
339
+ };
340
+
341
+ resetModules();
342
+ });
343
+
344
+ afterEach(() => {
345
+ onAfterResetModules = null;
346
+ });
347
+
348
itRenders('a blank div', async render => {
349
const e = await render(<div />);
350
expect(e.tagName).toBe('DIV');
360
expect(e.childNodes.length).toBe(1);
361
expect(e.firstChild.tagName).toBe('BR');
362
});
363
+
364
+ if (ReactDOMFeatureFlags.useFiber) {
365
+ itRenders('a array type children as a child', async render => {
366
+ let Header = props => {
367
+ return <p>header</p>;
368
+ };
369
+ let Footer = props => {
370
+ return [<h2 key={1}>footer</h2>, <h3 key={2}>about</h3>];
371
+ };
372
+ let e = await render([
373
+ <div key={1}>text1</div>,
374
+ <span key={2}>text2</span>,
375
+ <Header key={3} />,
376
+ <Footer key={4} />,
377
+ ]);
378
+ let parent = e.parentNode;
379
+ expect(parent.childNodes[0].tagName).toBe('DIV');
380
+ expect(parent.childNodes[1].tagName).toBe('SPAN');
381
+ expect(parent.childNodes[2].tagName).toBe('P');
382
+ expect(parent.childNodes[3].tagName).toBe('H2');
383
+ expect(parent.childNodes[4].tagName).toBe('H3');
384
+ });
385
+
386
+ itRenders('a single array element children as a child', async render => {
387
+ let e = await render([<div key={1}>text1</div>]);
388
+ let parent = e.parentNode;
389
+ expect(parent.childNodes[0].tagName).toBe('DIV');
390
+ });
391
+
392
+ itRenders('a nested array children as a child', async render => {
393
+ let e = await render([
394
+ [<div key={1}>text1</div>],
395
+ <span key={1}>text2</span>,
396
+ [[[null, <p key={1} />], false]],
397
+ ]);
398
+ let parent = e.parentNode;
399
+ expect(parent.childNodes[0].tagName).toBe('DIV');
400
+ expect(parent.childNodes[1].tagName).toBe('SPAN');
401
+ expect(parent.childNodes[2].tagName).toBe('P');
402
+ });
403
+
404
+ itRenders('an iterable as a child', async render => {
405
+ const threeDivIterable = {
406
+ '@@iterator': function() {
407
+ var i = 0;
408
+ return {
409
+ next: function() {
410
+ if (i++ < 3) {
411
+ return {value: <div key={i} />, done: false};
412
+ } else {
413
+ return {value: undefined, done: true};
414
+ }
415
+ },
416
+ };
417
+ },
418
+ };
419
+ let e = await render(threeDivIterable);
420
+ let parent = e.parentNode;
421
+ expect(parent.childNodes.length).toBe(3);
422
+ expect(parent.childNodes[0].tagName).toBe('DIV');
423
+ expect(parent.childNodes[1].tagName).toBe('DIV');
424
+ expect(parent.childNodes[2].tagName).toBe('DIV');
425
+ });
426
+ }
427
});
428
429
describe('property to attribute mapping', function() {