/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */

import { expression, statement } from '../../../tests/utils';
import isReactComponentMethod from '../isReactComponentMethod';

describe('isReactComponentMethod', () => {
  it('returns true if the method is a component class method', () => {
    const def = statement('class Foo { render() {}}');
    const method = def.get('body', 'body', 0);
    expect(isReactComponentMethod(method)).toBe(true);
  });

  it('returns true if the method is a component `createClass` object method', () => {
    const def = expression('{ render() {}}');
    const method = def.get('properties', 0);
    expect(isReactComponentMethod(method)).toBe(true);
  });

  it('returns false if the method is not a component class method', () => {
    const def = statement('class Foo { bar() {}}');
    const method = def.get('body', 'body', 0);
    expect(isReactComponentMethod(method)).toBe(false);
  });

  it('returns false if the method is not a component `createClass` object method', () => {
    const def = expression('{ bar() {}}');
    const method = def.get('properties', 0);
    expect(isReactComponentMethod(method)).toBe(false);
  });

  it('returns false if the path is not a method or object property', () => {
    const def = statement('let foo = "bar";');
    expect(isReactComponentMethod(def)).toBe(false);
  });
});

@@ -194,16 +194,18 @@
 import %7B
+%0A 
  express
@@ -208,16 +208,18 @@
 ression,
+%0A 
  stateme
@@ -220,17 +220,54 @@
 tatement
- 
+,%0A  noopImporter,%0A  makeMockImporter,%0A
 %7D from '
@@ -397,16 +397,144 @@
 () =%3E %7B%0A
+  const mockImporter = makeMockImporter(%7B%0A    foo: statement(%60%0A      export default 'render';%0A    %60).get('declaration'),%0A  %7D);%0A%0A
   it('re
@@ -730,32 +730,46 @@
 entMethod(method
+, noopImporter
 )).toBe(true);%0A 
@@ -983,32 +983,46 @@
 entMethod(method
+, noopImporter
 )).toBe(true);%0A 
@@ -1234,32 +1234,46 @@
 entMethod(method
+, noopImporter
 )).toBe(false);%0A
@@ -1498,16 +1498,30 @@
 d(method
+, noopImporter
 )).toBe(
@@ -1696,28 +1696,321 @@
 thod(def
-)).toBe(fals
+, noopImporter)).toBe(false);%0A  %7D);%0A%0A  it('resolves imported value of computed property', () =%3E %7B%0A    const def = statement(%60%0A      class Foo %7B %5Bfoo%5D() %7B%7D%7D%0A      import foo from 'foo';%0A    %60);%0A    const method = def.get('body', 'body', 0);%0A    expect(isReactComponentMethod(method, mockImporter)).toBe(tru
 e);%0A  %7D)

Add importer tests for isReactComponentMethod