<commit_before>import React, { Component } from 'react';
import createShallowRenderer from './helpers/createShallowRenderer';
import expect from 'expect';
import { createProxy } from '../src';

const fixtures = {
  modern: {
    Bar: class Bar {
      componentWillUnmount() {
        this.didUnmount = true;
      }

      render() {
        return <div>Bar</div>;
      }
    },
    Baz: class Baz {
      componentWillUnmount() {
        this.didUnmount = true;
      }

      render() {
        return <div>Baz</div>;
      }
    },
    Foo: class Foo {
      componentWillUnmount() {
        this.didUnmount = true;
      }

      render() {
        return <div>Foo</div>;
      }
    }
  },

  classic: {
    Bar: React.createClass({
      componentWillUnmount() {
        this.didUnmount = true;
      },

      render() {
        return <div>Bar</div>;
      }
    }),

    Baz: React.createClass({
      componentWillUnmount() {
        this.didUnmount = true;
      },

      render() {
        return <div>Baz</div>;
      }
    }),

    Foo: React.createClass({
      componentWillUnmount() {
        this.didUnmount = true;
      },

      render() {
        return <div>Foo</div>;
      }
    })
  }
};

describe('consistency', () => {
  let renderer;
  let warnSpy;

  beforeEach(() => {
    renderer = createShallowRenderer();
    warnSpy = expect.spyOn(console, 'warn').andCallThrough();
  });

  afterEach(() => {
    warnSpy.destroy();
    expect(warnSpy.calls.length).toBe(0);
  });

  Object.keys(fixtures).forEach(type => {
    describe(type, () => {
      const { Bar, Baz, Foo } = fixtures[type];

      it('does not overwrite the original class', () => {
        const proxy = createProxy(Bar);
        const BarProxy = proxy.get();
        const barInstance = renderer.render(<BarProxy />);
        expect(renderer.getRenderOutput().props.children).toEqual('Bar');

        proxy.update(Baz);
        const realBarInstance = renderer.render(<Bar />);
        expect(renderer.getRenderOutput().props.children).toEqual('Bar');
        expect(barInstance).toNotEqual(realBarInstance);
        expect(barInstance.didUnmount).toEqual(true);
      });

      it('sets up constructor to match the type', () => {
        let proxy = createProxy(Bar);
        const BarProxy = proxy.get();
        const barInstance = renderer.render(<BarProxy />);
        expect(barInstance.constructor).toEqual(BarProxy);
        expect(barInstance instanceof BarProxy).toEqual(true);

        proxy.update(Baz);
        const BazProxy = proxy.get();
        expect(BarProxy).toEqual(BazProxy);
        expect(barInstance.constructor).toEqual(BazProxy);
        expect(barInstance instanceof BazProxy).toEqual(true);
      });

      it('sets up displayName from displayName or name', () => {
        let proxy = createProxy(Bar);
        const BarProxy = proxy.get();
        const barInstance = renderer.render(<BarProxy />);
        expect(barInstance.constructor.displayName).toEqual('Bar');

        proxy.update(Baz);
        const BazProxy = proxy.get();
        expect(BarProxy).toEqual(BazProxy);
        expect(barInstance.constructor.displayName).toEqual('Baz');
      });
    });
  });

  describe('classic only', () => {
    const { Bar, Baz } = fixtures.classic;

    it('sets up legacy type property', () => {
      let proxy = createProxy(Bar);
      const BarProxy = proxy.get();
      const barInstance = renderer.render(<BarProxy />);
      expect(barInstance.constructor.type).toEqual(BarProxy);

      proxy.update(Baz);
      const BazProxy = proxy.get();
      expect(BarProxy).toEqual(BazProxy);
      expect(barInstance.constructor.type).toEqual(BazProxy);

      expect(warnSpy.calls.length).toBe(1);
      warnSpy.calls = [];
    });
  });
});<commit_msg>Remove expected warning from log<commit_after>import React, { Component } from 'react';
import createShallowRenderer from './helpers/createShallowRenderer';
import expect from 'expect';
import { createProxy } from '../src';

const fixtures = {
  modern: {
    Bar: class Bar {
      componentWillUnmount() {
        this.didUnmount = true;
      }

      render() {
        return <div>Bar</div>;
      }
    },
    Baz: class Baz {
      componentWillUnmount() {
        this.didUnmount = true;
      }

      render() {
        return <div>Baz</div>;
      }
    },
    Foo: class Foo {
      componentWillUnmount() {
        this.didUnmount = true;
      }

      render() {
        return <div>Foo</div>;
      }
    }
  },

  classic: {
    Bar: React.createClass({
      componentWillUnmount() {
        this.didUnmount = true;
      },

      render() {
        return <div>Bar</div>;
      }
    }),

    Baz: React.createClass({
      componentWillUnmount() {
        this.didUnmount = true;
      },

      render() {
        return <div>Baz</div>;
      }
    }),

    Foo: React.createClass({
      componentWillUnmount() {
        this.didUnmount = true;
      },

      render() {
        return <div>Foo</div>;
      }
    })
  }
};

describe('consistency', () => {
  let renderer;
  let warnSpy;

  beforeEach(() => {
    renderer = createShallowRenderer();
    warnSpy = expect.spyOn(console, 'warn').andCallThrough();
  });

  afterEach(() => {
    warnSpy.destroy();
    expect(warnSpy.calls.length).toBe(0);
  });

  Object.keys(fixtures).forEach(type => {
    describe(type, () => {
      const { Bar, Baz, Foo } = fixtures[type];

      it('does not overwrite the original class', () => {
        const proxy = createProxy(Bar);
        const BarProxy = proxy.get();
        const barInstance = renderer.render(<BarProxy />);
        expect(renderer.getRenderOutput().props.children).toEqual('Bar');

        proxy.update(Baz);
        const realBarInstance = renderer.render(<Bar />);
        expect(renderer.getRenderOutput().props.children).toEqual('Bar');
        expect(barInstance).toNotEqual(realBarInstance);
        expect(barInstance.didUnmount).toEqual(true);
      });

      it('sets up constructor to match the type', () => {
        let proxy = createProxy(Bar);
        const BarProxy = proxy.get();
        const barInstance = renderer.render(<BarProxy />);
        expect(barInstance.constructor).toEqual(BarProxy);
        expect(barInstance instanceof BarProxy).toEqual(true);

        proxy.update(Baz);
        const BazProxy = proxy.get();
        expect(BarProxy).toEqual(BazProxy);
        expect(barInstance.constructor).toEqual(BazProxy);
        expect(barInstance instanceof BazProxy).toEqual(true);
      });

      it('sets up displayName from displayName or name', () => {
        let proxy = createProxy(Bar);
        const BarProxy = proxy.get();
        const barInstance = renderer.render(<BarProxy />);
        expect(barInstance.constructor.displayName).toEqual('Bar');

        proxy.update(Baz);
        const BazProxy = proxy.get();
        expect(BarProxy).toEqual(BazProxy);
        expect(barInstance.constructor.displayName).toEqual('Baz');
      });
    });
  });

  describe('classic only', () => {
    const { Bar, Baz } = fixtures.classic;

    it('sets up legacy type property', () => {
      let proxy = createProxy(Bar);
      const BarProxy = proxy.get();
      const barInstance = renderer.render(<BarProxy />);

      warnSpy.destroy();

      const localWarnSpy = expect.spyOn(console, 'warn');
      expect(barInstance.constructor.type).toEqual(BarProxy);

      proxy.update(Baz);
      const BazProxy = proxy.get();
      expect(BarProxy).toEqual(BazProxy);
      expect(barInstance.constructor.type).toEqual(BazProxy);

      expect(localWarnSpy.calls.length).toBe(1);
      localWarnSpy.destroy();
    });
  });
});
{'fraction_non_alphanumeric': 0.14877001171417414, 'fraction_numerical': 0.0005206299622543278, 'mean_word_length': 2.4690744920993226, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 57, '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': '5204750', 'n_tokens_mistral': 2319, 'n_tokens_neox': 2280, 'n_words': 403}