"use strict";

var _updateArrayWithDefault = require("../updateArrayWithDefault");

describe('getArrayWithDefault with custom isEqual', () => {
  const mapper = a => a === '...' ? a : {
    subKey: a
  };

  const defaultValuesArray = ['a', 'b', 'c', 'd', 'e'].map(mapper);

  const customIsEqual = (a, b) => a.subKey === b.subKey;

  it('usual extra one option in the last', () => {
    const values = (0, _updateArrayWithDefault.getArrayWithDefault)(['...', 'z'].map(mapper), defaultValuesArray, customIsEqual);
    const expectedValue = ['a', 'b', 'c', 'd', 'e', 'z'].map(mapper);
    expect(values).toEqual(expectedValue);
  });
  it('usual extra 2 option in the last', () => {
    const values = (0, _updateArrayWithDefault.getArrayWithDefault)(['...', 'z', 'y'].map(mapper), defaultValuesArray, customIsEqual);
    const expectedValue = ['a', 'b', 'c', 'd', 'e', 'z', 'y'].map(mapper);
    expect(values).toEqual(expectedValue);
  });
  it('usual extra one option in the front', () => {
    const values = (0, _updateArrayWithDefault.getArrayWithDefault)(['z', '...'].map(mapper), defaultValuesArray, customIsEqual);
    const expectedValue = ['z', 'a', 'b', 'c', 'd', 'e'].map(mapper);
    expect(values).toEqual(expectedValue);
  });
  it('usual extra 2 option in the front', () => {
    const values = (0, _updateArrayWithDefault.getArrayWithDefault)(['z', 'y', '...'].map(mapper), defaultValuesArray, customIsEqual);
    const expectedValue = ['z', 'y', 'a', 'b', 'c', 'd', 'e'].map(mapper);
    expect(values).toEqual(expectedValue);
  });
  it('usual already given one option in the last', () => {
    const values = (0, _updateArrayWithDefault.getArrayWithDefault)(['...', 'c'].map(mapper), defaultValuesArray, customIsEqual);
    const expectedValue = ['a', 'b', 'd', 'e', 'c'].map(mapper);
    expect(values).toEqual(expectedValue);
  });
  it('usual already given 2 option in the last', () => {
    const values = (0, _updateArrayWithDefault.getArrayWithDefault)(['...', 'd', 'b'].map(mapper), defaultValuesArray, customIsEqual);
    const expectedValue = ['a', 'c', 'e', 'd', 'b'].map(mapper);
    expect(values).toEqual(expectedValue);
  });
  it('usual already given one option in the front', () => {
    const values = (0, _updateArrayWithDefault.getArrayWithDefault)(['c', '...'].map(mapper), defaultValuesArray, customIsEqual);
    const expectedValue = ['c', 'a', 'b', 'd', 'e'].map(mapper);
    expect(values).toEqual(expectedValue);
  });
  it('usual already given 2 option in the front', () => {
    const values = (0, _updateArrayWithDefault.getArrayWithDefault)(['b', 'd', '...'].map(mapper), defaultValuesArray, customIsEqual);
    const expectedValue = ['b', 'd', 'a', 'c', 'e'].map(mapper);
    expect(values).toEqual(expectedValue);
  });
});