import { omitAll } from './omitAll';

describe('omitAll', () => {
  test('should omit all keys from an object', () => {
    const obj = {
      name: 'John',
      __typename: {
        name: 'John'
      }
    };
    const newObj = omitAll(obj, ['__typename']);
    expect(newObj).toEqual({
      name: 'John'
    });
  });

  test('should omit all keys recursively from an object', () => {
    const obj = {
      name: 'John',
      __typename: {
        name: 'John'
      },
      address: {
        __typename: {
          name: 'John'
        },
        city: 'New York',
        country: 'USA'
      }
    };
    const newObj = omitAll(obj, ['__typename']);
    expect(newObj).toEqual({
      name: 'John',
      address: {
        city: 'New York',
        country: 'USA'
      }
    });
  });
  test('should omit all keys in the array from an object', () => {
    const obj = {
      name: 'John',
      age: 25,
      city: 'New York',
      country: 'USA'
    };
    const newObj = omitAll(obj, ['name', 'age', 'city', 'country']);
    expect(newObj).toEqual({});
  });
});
