<commit_before>/* global chai, expect, sinon */
/* eslint-env mocha */
/* eslint-disable react/prop-types, react/no-multi-comp, no-unused-expressions */
import React, { Component } from 'react';
import { shallow, mount } from 'enzyme';
import chaiEnzyme from 'chai-enzyme';

import { getContainerBox, getTagPositions } from './helpers';
import FlipMove from '../src/FlipMove';

chai.use(chaiEnzyme());

describe('FlipMove', () => {
  let consoleStub;
  let finishAllStub;

  before(() => {
    consoleStub = sinon.stub(console, 'error');
    finishAllStub = sinon.stub();
  });
  afterEach(() => {
    consoleStub.reset();
    finishAllStub.reset();
  });
  after(() => consoleStub.restore());

  // To test this, here is our setup:
  // We're making a simple list of news articles, with the ability to
  // change them from sorting ascending vs. descending.
  // Doing so will cause the items to be re-rendered in a different
  // order, and we want the transition to be animated.
  const articles = [
    { id: 'a', name: 'The Dawn of Time', timestamp: 123456 },
    { id: 'b', name: 'A While Back', timestamp: 333333 },
    { id: 'c', name: 'This Just Happened', timestamp: 654321 },
  ];

  // We need a list item, the thing we'll be moving about.
  // eslint-disable-next-line react/prefer-stateless-function
  const ListItem = class ListItem extends Component {
    render() {
      return <li id={this.props.id}>{this.props.name}</li>;
    }
  };
  // We need our list parent, which contains our FlipMove as well as
  // all the list items.
  const ListParent = class ListParent extends Component {
    static defaultProps = {
      duration: 500,
      staggerDelayBy: 0,
      staggerDurationBy: 0,
      disableAllAnimations: false,
      maintainContainerHeight: false,
      articles,<commit_msg>Increase CI tests stability by replacing window.requestAnimationFrame with setTimeout in tests. (#175)<commit_after>/* global chai, expect, sinon */
/* eslint-env mocha */
/* eslint-disable react/prop-types, react/no-multi-comp, no-unused-expressions */
import React, { Component } from 'react';
import { shallow, mount } from 'enzyme';
import chaiEnzyme from 'chai-enzyme';

import { getContainerBox, getTagPositions } from './helpers';
import FlipMove from '../src/FlipMove';

chai.use(chaiEnzyme());

describe('FlipMove', () => {
  let consoleStub;
  let finishAllStub;

  before(() => {
    sinon.stub(window, 'requestAnimationFrame', cb => setTimeout(cb, 0));
    consoleStub = sinon.stub(console, 'error');
    finishAllStub = sinon.stub();
  });
  afterEach(() => {
    consoleStub.reset();
    finishAllStub.reset();
  });
  after(() => {
    window.requestAnimationFrame.restore();
    consoleStub.restore();
  });

  // To test this, here is our setup:
  // We're making a simple list of news articles, with the ability to
  // change them from sorting ascending vs. descending.
  // Doing so will cause the items to be re-rendered in a different
  // order, and we want the transition to be animated.
  const articles = [
    { id: 'a', name: 'The Dawn of Time', timestamp: 123456 },
    { id: 'b', name: 'A While Back', timestamp: 333333 },
    { id: 'c', name: 'This Just Happened', timestamp: 654321 },
  ];

  // We need a list item, the thing we'll be moving about.
  // eslint-disable-next-line react/prefer-stateless-function
  const ListItem = class ListItem extends Component {
    render() {
      return <li id={this.props.id}>{this.props.name}</li>;
    }
  };
  // We need our list parent, which contains our FlipMove as well as
  // all the list items.
  const ListParent = class ListParent extends Component {
    static defaultProps = {
      duration: 500,
      staggerDelayBy: 0,
      staggerDurationBy: 0,
      disableAllAnimations: false,
      maintainContainerHeight: false,
      articles,
{'fraction_non_alphanumeric': 0.13249869587897756, 'fraction_numerical': 0.013041210224308816, 'mean_word_length': 3.308988764044944, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7276489', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1167, 'n_words': 382}