import findUsedIdentifiers from '../findUsedIdentifiers';
import parse from '../parse';

it('finds used variables', () => {
  expect(
    findUsedIdentifiers(
      parse(
        `
    api.something();
    const foo = 'foo';
    foo();
    bar();
  `,
      ),
    ),
  ).toEqual(new Set(['api', 'foo', 'bar']));
});

it('knows about jsx', () => {
  expect(
    findUsedIdentifiers(
      parse(
        `
    <Foo bar={far.foo()}/>
  `,
      ),
    ),
  ).toEqual(new Set(['far', 'React', 'Foo']));
});

it('knows about flow annotations', () => {
  expect(
    findUsedIdentifiers(
      parse(
        `
    class Foo {
      bar: Car;
    }
  `,
      ),
    ),
  ).toEqual(new Set(['Car']));
});

it('knows about export declarations', () => {
  expect(
    findUsedIdentifiers(
      parse(
        `
        export { foo as bar }
        export { baz }
  `,
      ),
    ),
  ).toEqual(new Set(['foo', 'baz']));
});

it('treats items in arrays as used', () => {
  expect(
    findUsedIdentifiers(
      parse(
        `
    [Foo, Bar]
  `,
      ),
    ),
  ).toEqual(new Set(['Foo', 'Bar']));
});

it('treats items used as arguments as used', () => {
  expect(
    findUsedIdentifiers(
      parse(
        `
    foo(Foo, Bar);
  `,
      ),
    ),
  ).toEqual(new Set(['foo', 'Foo', 'Bar']));
});

import findUsedIdentifiers from '../findUsedIdentifiers';
import parse from '../parse';

it('finds used variables', () => {
  expect(
    findUsedIdentifiers(
      parse(
        `
    api.something();
    const foo = 'foo';
    foo();
    bar();
  `,
      ),
    ),
  ).toEqual(new Set(['api', 'foo', 'bar']));
});

it('knows about jsx', () => {
  expect(
    findUsedIdentifiers(
      parse(
        `
    <Foo bar={far.foo()}/>
  `,
      ),
    ),
  ).toEqual(new Set(['far', 'React', 'Foo']));
});

it('knows about flow annotations', () => {
  expect(
    findUsedIdentifiers(
      parse(
        `
    class Foo {
      bar: Car;
    }
  `,
      ),
    ),
  ).toEqual(new Set(['Car']));
});

it('treats items in arrays as used', () => {
  expect(
    findUsedIdentifiers(
      parse(
        `
    [Foo, Bar]
  `,
      ),
    ),
  ).toEqual(new Set(['Foo', 'Bar']));
});

it('treats items used as arguments as used', () => {
  expect(
    findUsedIdentifiers(
      parse(
        `
    foo(Foo, Bar);
  `,
      ),
    ),
  ).toEqual(new Set(['foo', 'Foo', 'Bar']));
});

--- 
+++ 
@@ -42,6 +42,19 @@
   ).toEqual(new Set(['Car']));
 });
 
+it('knows about export declarations', () => {
+  expect(
+    findUsedIdentifiers(
+      parse(
+        `
+        export { foo as bar }
+        export { baz }
+  `,
+      ),
+    ),
+  ).toEqual(new Set(['foo', 'baz']));
+});
+
 it('treats items in arrays as used', () => {
   expect(
     findUsedIdentifiers(
Add test for export declarations to findUsedIdentifiers

I recently added some test that changed how identifiers were visited,
and I just wanted to make sure I didn't break anything for the
findUsedIdentifiers module.
