it('returns the appropriate values when allegationsEdits is null', () => {
   const allegationsEdits = null
   const participants = Immutable.fromJS([archer, malory])
   const allegations = Immutable.fromJS([
     {id: '123', screening_id: '3', victim_id: '1', perpetrator_id: '2'},
   ])
   const result = sortedAllegationsList(screeningId, participants, allegations, allegationsEdits)
   const expectedResult = Immutable.fromJS([
     {id: '123', screening_id: screeningId, allegation_types: [], victim_id: archer.id, victim: archer, perpetrator_id: malory.id, perpetrator: malory},
   ])
   expect(result.toJS()).toEqual(expectedResult.toJS())
   expect(Immutable.is(result, expectedResult)).toEqual(true)
 })
 it('merges the allegationsEdits into the returned allegations', () => {
   const allegationsEdits = Immutable.fromJS({1: {2: ['General neglect']}})
   const participants = Immutable.fromJS([archer, malory])
   const allegations = Immutable.fromJS([
     {id: '123', screening_id: '3', victim_id: '1', perpetrator_id: '2'},
   ])
   const result = sortedAllegationsList(screeningId, participants, allegations, allegationsEdits)
   const expectedResult = Immutable.fromJS([
     {id: '123', screening_id: screeningId, allegation_types: ['General neglect'], victim_id: archer.id, victim: archer, perpetrator_id: malory.id, perpetrator: malory},
   ])
   expect(result.toJS()).toEqual(expectedResult.toJS())
   expect(Immutable.is(result, expectedResult)).toEqual(true)
 })
  it('sorts victims with the same birth date and last name based on first name', () => {
    const malory = {id: '2', first_name: 'Malory', last_name: 'Archer', date_of_birth: '2005-01-01', roles: ['Victim']}
    const cyril = {id: '4', first_name: 'Cyril', last_name: 'Figgus', date_of_birth: '2008-01-01', roles: ['Perpetrator']}
    const archer = {id: '1', first_name: 'Sterling', last_name: 'Archer', date_of_birth: '2005-01-01', roles: ['Victim']}

    const participants = Immutable.fromJS([cyril, archer, malory])
    const result = sortedAllegationsList(screeningId, participants, allegations)
    const expectedResult = Immutable.fromJS([
      {id: null, screening_id: screeningId, allegation_types: [], victim_id: malory.id, victim: malory, perpetrator_id: cyril.id, perpetrator: cyril},
      {id: null, screening_id: screeningId, allegation_types: [], victim_id: archer.id, victim: archer, perpetrator_id: cyril.id, perpetrator: cyril},
    ])

    expect(result.toJS()).toEqual(expectedResult.toJS())
    expect(Immutable.is(result, expectedResult)).toEqual(true)
  })
 it('returns combinations of victims and perpetrators', () => {
   const participants = Immutable.fromJS([archer, malory, cyril, lana, pam])
   const allegations = Immutable.List()
   const result = sortedAllegationsList(screeningId, participants, allegations)
   const expectedResult = Immutable.fromJS([
     {id: null, screening_id: screeningId, allegation_types: [], victim_id: archer.id, victim: archer, perpetrator_id: malory.id, perpetrator: malory},
     {id: null, screening_id: screeningId, allegation_types: [], victim_id: archer.id, victim: archer, perpetrator_id: lana.id, perpetrator: lana},
     {id: null, screening_id: screeningId, allegation_types: [], victim_id: pam.id, victim: pam, perpetrator_id: malory.id, perpetrator: malory},
     {id: null, screening_id: screeningId, allegation_types: [], victim_id: pam.id, victim: pam, perpetrator_id: archer.id, perpetrator: archer},
     {id: null, screening_id: screeningId, allegation_types: [], victim_id: pam.id, victim: pam, perpetrator_id: lana.id, perpetrator: lana},
   ])
   expect(result.toJS()).toEqual(expectedResult.toJS())
   expect(result.size).toEqual(5)
   expect(Immutable.is(result, expectedResult)).toEqual(true)
 })
  it('within a victim group, sorts perpetrators with the same birth date when both have no last name', () => {
    const malory = {id: '2', first_name: 'Malory', last_name: 'Archer', date_of_birth: '1990-02-02', roles: ['Victim']}
    const cyril = {id: '4', first_name: 'Cyril', date_of_birth: '2005-01-01', roles: ['Perpetrator']}
    const archer = {id: '1', first_name: 'Sterling', date_of_birth: '2005-01-01', roles: ['Perpetrator']}

    const participants = Immutable.fromJS([malory, archer, cyril])
    const result = sortedAllegationsList(screeningId, participants, allegations)
    const expectedResult = Immutable.fromJS([
      {id: null, screening_id: screeningId, allegation_types: [], victim_id: malory.id, victim: malory, perpetrator_id: cyril.id, perpetrator: cyril},
      {id: null, screening_id: screeningId, allegation_types: [], victim_id: malory.id, victim: malory, perpetrator_id: archer.id, perpetrator: archer},
    ])

    expect(result.toJS()).toEqual(expectedResult.toJS())
    expect(Immutable.is(result, expectedResult)).toEqual(true)
  })
 it('does not add allegations when all possible allegations are persisted', () => {
   const participants = Immutable.fromJS([archer, malory, pam])
   const allegations = Immutable.fromJS([
     {id: '123', screening_id: '3', victim_id: '1', perpetrator_id: '2'},
     {id: '456', screening_id: '3', victim_id: '6', perpetrator_id: '1'},
     {id: '789', screening_id: '3', victim_id: '6', perpetrator_id: '2'},
   ])
   const result = sortedAllegationsList(screeningId, participants, allegations)
   const expectedResult = Immutable.fromJS([
     {id: '123', screening_id: screeningId, allegation_types: [], victim_id: archer.id, victim: archer, perpetrator_id: malory.id, perpetrator: malory},
     {id: '789', screening_id: screeningId, allegation_types: [], victim_id: pam.id, victim: pam, perpetrator_id: malory.id, perpetrator: malory},
     {id: '456', screening_id: screeningId, allegation_types: [], victim_id: pam.id, victim: pam, perpetrator_id: archer.id, perpetrator: archer},
   ])
   expect(result.toJS()).toEqual(expectedResult.toJS())
   expect(result.size).toEqual(3)
   expect(Immutable.is(result, expectedResult)).toEqual(true)
 })
 it('interleaves possible and persisted allegations', () => {
   const participants = Immutable.fromJS([archer, malory, pam, cyril, lana])
   const allegations = Immutable.fromJS([
     {id: '123', screening_id: '3', victim_id: '1', perpetrator_id: '2'},
     {id: '456', screening_id: '3', victim_id: '6', perpetrator_id: '1'},
     {id: '789', screening_id: '3', victim_id: '6', perpetrator_id: '2'},
   ])
   const result = sortedAllegationsList(screeningId, participants, allegations)
   const expectedResult = Immutable.fromJS([
     {id: '123', screening_id: screeningId, allegation_types: [], victim_id: archer.id, victim: archer, perpetrator_id: malory.id, perpetrator: malory},
     {id: null, screening_id: screeningId, allegation_types: [], victim_id: archer.id, victim: archer, perpetrator_id: lana.id, perpetrator: lana},
     {id: '789', screening_id: screeningId, allegation_types: [], victim_id: pam.id, victim: pam, perpetrator_id: malory.id, perpetrator: malory},
     {id: '456', screening_id: screeningId, allegation_types: [], victim_id: pam.id, victim: pam, perpetrator_id: archer.id, perpetrator: archer},
     {id: null, screening_id: screeningId, allegation_types: [], victim_id: pam.id, victim: pam, perpetrator_id: lana.id, perpetrator: lana},
   ])
   expect(result.toJS()).toEqual(expectedResult.toJS())
   expect(result.size).toEqual(5)
   expect(Immutable.is(result, expectedResult)).toEqual(true)
 })
 it('returns an empty list when there are no victims or perpetrators', () => {
   expect(sortedAllegationsList(screeningId, Immutable.List(), Immutable.List())).toEqual(
     Immutable.List()
   )
 })