import {fromJS} from 'immutable';

import {getToUser} from './selector';

describe('widget-space selectors', () => {
  const otherUser = {
    entryEmail: 'ccwexpress@sparkbot.io',
    displayName: 'Nakia - Personal Assistant',
    entryUUID: '889869a1-f5b9-408b-a514-12704f02817a',
    emailAddress: 'ccwexpress@sparkbot.io',
    objectType: 'person',
    type: 'ROBOT',
    id: '889869a1-f5b9-408b-a514-12704f02817a',
    orgId: '1eb65fdf-9643-417f-9974-ad72cae0e10f'
  };
  it('gets the "to user"', () => {
    const currentUser = {
      entryEmail: 'qtcrabfq6f@2cecfb0e-f9fc-45cb-b8fc-1f9ebf87209b',
      displayName: 'User-qTCRABFq6f',
      entryUUID: '1c8ce4a0-df7b-4e62-8020-a1a430581e51',
      emailAddress: 'qtcrabfq6f@2cecfb0e-f9fc-45cb-b8fc-1f9ebf87209b',
      objectType: 'person',
      type: 'APPUSER',
      id: '1c8ce4a0-df7b-4e62-8020-a1a430581e51',
      orgId: '2cecfb0e-f9fc-45cb-b8fc-1f9ebf87209b'
    };

    const mockedConversation = fromJS({
      participants: [currentUser, otherUser]
    });

    const toUser = getToUser.resultFunc(mockedConversation, currentUser);
    expect(toUser.get('displayName')).toBe(otherUser.displayName);
  });
  it('gets the "to user" with capitalized email', () => {
    const currentUser = {
      entryEmail: 'qTCRABFq6f@2cecfb0e-f9fc-45cb-b8fc-1f9ebf87209b',
      displayName: 'User-qTCRABFq6f',
      entryUUID: '1c8ce4a0-df7b-4e62-8020-a1a430581e51',
      emailAddress: 'qTCRABFq6f@2cecfb0e-f9fc-45cb-b8fc-1f9ebf87209b',
      objectType: 'person',
      type: 'APPUSER',
      id: '1c8ce4a0-df7b-4e62-8020-a1a430581e51',
      orgId: '2cecfb0e-f9fc-45cb-b8fc-1f9ebf87209b'
    };

    const mockedConversation = fromJS({
      participants: [currentUser, otherUser]
    });

    const toUser = getToUser.resultFunc(mockedConversation, currentUser);
    expect(toUser.get('displayName')).toBe(otherUser.displayName);
  });
});

import {fromJS} from 'immutable';

import {getToUser} from './selector';

describe('widget-space selectors', () => {
  const otherUser = {
    entryEmail: 'fakebot@sparkbot.io',
    displayName: 'Personal Assistant Bot',
    entryUUID: 'c04b6751-bbed-4ac8-aa63-9654b757e171',
    emailAddress: 'fakebot@sparkbot.io',
    objectType: 'person',
    type: 'ROBOT',
    id: 'c04b6751-bbed-4ac8-aa63-9654b757e171',
    orgId: 'ac9c7b0d-77e3-4ab9-b8f6-b092c57e5999'
  };
  it('gets the "to user"', () => {
    const currentUser = {
      entryEmail: 'qtcrabfq6f@4c45deca-dc35-4c44-9941-b0c7ba8f7b13',
      displayName: 'User-qTCRABFq6f',
      entryUUID: '1c8ce4a0-df7b-4e62-8020-a1a430581e51',
      emailAddress: 'qtcrabfq6f@4c45deca-dc35-4c44-9941-b0c7ba8f7b13',
      objectType: 'person',
      type: 'APPUSER',
      id: '1c8ce4a0-df7b-4e62-8020-a1a430581e51',
      orgId: '4c45deca-dc35-4c44-9941-b0c7ba8f7b13'
    };

    const mockedConversation = fromJS({
      participants: [currentUser, otherUser]
    });

    const toUser = getToUser.resultFunc(mockedConversation, currentUser);
    expect(toUser.get('displayName')).toBe(otherUser.displayName);
  });
  it('gets the "to user" with capitalized email', () => {
    const currentUser = {
      entryEmail: 'qTCRABFq6f@4c45deca-dc35-4c44-9941-b0c7ba8f7b13',
      displayName: 'User-qTCRABFq6f',
      entryUUID: '1c8ce4a0-df7b-4e62-8020-a1a430581e51',
      emailAddress: 'qTCRABFq6f@4c45deca-dc35-4c44-9941-b0c7ba8f7b13',
      objectType: 'person',
      type: 'APPUSER',
      id: '1c8ce4a0-df7b-4e62-8020-a1a430581e51',
      orgId: '4c45deca-dc35-4c44-9941-b0c7ba8f7b13'
    };

    const mockedConversation = fromJS({
      participants: [currentUser, otherUser]
    });

    const toUser = getToUser.resultFunc(mockedConversation, currentUser);
    expect(toUser.get('displayName')).toBe(otherUser.displayName);
  });
});

rename IDs