"use strict";

var _index = require("../index");

describe('passing different datatypes to schema', () => {
  const customOptions = {};
  const processEnv = {};
  it('Passing string to schema', () => {
    const schema = '';
    const output = (0, _index.applyValuesToSchema)(schema, customOptions, processEnv);
    expect(output).toStrictEqual({});
  });
  it('Passing number to schema', () => {
    const schema = 28;
    const output = (0, _index.applyValuesToSchema)(schema, customOptions, processEnv);
    expect(output).toStrictEqual({});
  });
  it('Passing Number array to schema', () => {
    const schema = [1, 3, 4];
    const output = (0, _index.applyValuesToSchema)(schema, customOptions, processEnv);
    expect(output).toStrictEqual({
      0: 1,
      1: 3,
      2: 4
    });
  });
  it('Passing String array to schema', () => {
    const schema = ['Testing', 'the', 'code'];
    const output = (0, _index.applyValuesToSchema)(schema, customOptions, processEnv);
    expect(output).toStrictEqual({
      0: 'Testing',
      1: 'the',
      2: 'code'
    });
  });
  it('Passing 2D array to schema', () => {
    const schema = ['Testing', 'the', 'code', [1, 2], ['hi', 'buddy'], {
      firstData: 'one'
    }];
    const output = (0, _index.applyValuesToSchema)(schema, customOptions, processEnv);
    expect(output).toStrictEqual({
      0: 'Testing',
      1: 'the',
      2: 'code',
      3: [1, 2],
      4: ['hi', 'buddy'],
      5: {
        firstData: 'one'
      }
    });
  });
  it('Passing object to schema', () => {
    const schema = {
      firstData: 1,
      secondData: 2
    };
    const output = (0, _index.applyValuesToSchema)(schema, customOptions, processEnv);
    expect(output).toStrictEqual({
      firstData: 1,
      secondData: 2
    });
  });
  it('Passing Nested object to schema', () => {
    const schema = {
      firstData: 1,
      secondData: 2,
      nestedObject: {
        nestedObject1: 'hello',
        nestedObject2: 'hi'
      },
      secondObject: {
        thirdData: 3,
        fourthData: 'fourthData'
      }
    };
    const output = (0, _index.applyValuesToSchema)(schema, customOptions, processEnv);
    expect(output).toStrictEqual({
      firstData: 1,
      secondData: 2,
      nestedObject: {
        nestedObject1: 'hello',
        nestedObject2: 'hi'
      },
      secondObject: {
        thirdData: 3,
        fourthData: 'fourthData'
      }
    });
  });
  it('Passing null value to schema', () => {
    const schema = null;
    expect(() => (0, _index.applyValuesToSchema)(schema, customOptions, processEnv)).toThrow(Error);
  });
  it('Passing undefined value to schema', () => {
    const schema = undefined;
    expect(() => (0, _index.applyValuesToSchema)(schema, customOptions, processEnv)).toThrow(Error);
  });
  it('Passing NaN value to schema', () => {
    const schema = NaN;
    const output = (0, _index.applyValuesToSchema)(schema, customOptions, processEnv);
    expect(output).toStrictEqual({});
  });
});