import {normalizeInstruments} from './instruments';

describe('normalizeInstruments', () => {
  it('shouldWrapSingleInstrumentObjectInArray', () => {
    expect(normalizeInstruments({insId: 20, insNom: 'Violon'})).toEqual([
      {insId: 20, insNom: 'Violon'},
    ]);
  });

  it('shouldKeepArraysAndDropNullishOrIncompleteEntries', () => {
    expect(
      normalizeInstruments([
        {insId: 1, insNom: 'Bombarde'},
        null,
        undefined,
        {insId: 2},
        {insId: 3, insNom: 'Biniou'},
      ])
    ).toEqual([
      {insId: 1, insNom: 'Bombarde'},
      {insId: 3, insNom: 'Biniou'},
    ]);
  });

  it('shouldReturnEmptyArrayForNullish', () => {
    expect(normalizeInstruments(null)).toEqual([]);
    expect(normalizeInstruments(undefined)).toEqual([]);
  });
});
