import check from './objectContainsNonSerializableProperty';

describe('Object contains non serializable property checker', () => {
  it('Should return true for simple object', () => {
    const object = {
      name: 'Bob',
      age: 20,
      favoriteFoods: ['Hamburger', 'Pizza'],
      homeAddress: {
        addressLine1: '12345 Test Place',
        addressLine2: null,
        city: 'SomePlace',
        state: 'LA',
        zip: 12345,
      },
    };

    const result = check(object);
    expect(result).toBe(false);
  });

  it('Should return false for direct file property', () => {
    const object = {
      name: 'Bob',
      age: 20,
      profilePhoto: new File(['foo'], 'foo.txt', {
        type: 'text/plain',
      }),
    };

    const result = check(object);
    expect(result).toBe(true);
  });

  it('Should return false for deeply nested file property', () => {
    const object = {
      a: {
        b: {
          c: new File(['foo'], 'foo.txt', {
            type: 'text/plain',
          }),
        },
      },
    };

    const result = check(object);
    expect(result).toBe(true);
  });
});
